Jump to content

How do I switch printers from a script?


This topic is 7022 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Since this question has come up a few times, I thought I would post the Applescript solution to this problem here in the FAQ forum. If you are using a Mac with OS 8.6 or later, the following will allow you to select a desktop printer on the fly from a Filemaker script:

1. Create a Filemaker script.

2. Add a Perform AppleScript step. Click the "Specify..." button.

3. Select "Script Text", and paste the following code into into the text box:

code:


set RequestedPtr to "MyMainPrinter"

tell application "Desktop Printer Manager"

set CurrentPrtr to name of default printer

end tell

--See if the default printer is the one we want

if CurrentPrtr is not RequestedPtr then

--No. So, wait for the current printer's queue to empty

tell application "Finder"

repeat

--See if there are print jobs queued up.

set jobs to count of items in folder CurrentPrtr

if jobs < 1 then exit repeat

delay 10

-- wait 10 seconds and check again

end repeat

end tell

--No print jobs remaining. So, switch printers

tell application "Desktop Printer Manager"

set default printer to desktop printer RequestedPtr

end tell

end if


Variation

If you want to switch to a printer whose name is stored in a global field, do this:

1. Create a global text field called gPrtrScriptTemplate, and paste the above applescript code into it.

2. Create a global text field called gPrinterName, and enter a valid desktop printer name into it.

3. Create a calculated text field called PrinterScript with the formula:

Substitute(gPrtrScriptTemplate,"MyMainPrinter", gPrinterName)

Now create a Filemaker script again, as above, but instead of specifying "Script Text," specify "Field Value" and select PrinterScript as the field.

Now, whenever you want to switch printers, just perform the above script before you print.

Link to comment
Share on other sites

And for a Windows version....

The following utilities and plug-ins have been suggested from recent forum discussions (I have no personal experience with them)

http://softtechsolution.com

ProPrint http://www.afeina.com

Change Printer Plug-in www.productivecomputing.com

[Edit: added new products to list]

[ July 21, 2001: Message edited by: BobWeaver ]

Link to comment
Share on other sites

  • 10 months later...

quote:

Originally posted by BobWeaver:

And for a Windows version....

The following utilities and plug-ins have been suggested from recent forum discussions (I have no personal experience with them)

ProPrint

Change Printer Plug-in

[Edit: added new products to list]

Thanks a lot Bob, I will give a try and let you know.

Link to comment
Share on other sites

  • 2 years later...

Hi, Bob - quick question for you! I'm on FM6, Mac OS9.

Your AppleScript to switch printers is great! However, I just got a new DYMO Labelwriter 300 and I discovered that it's a USB printer, therefore it doesn't really like this script. What, if anything, can I substitute out to tell it to go to Chooser and find the USB printer (as the Requested, not default), print a label and come back to the default? I've angered FMP with the things I've tried thus far...

Link to comment
Share on other sites

  • 6 months later...

Hi Snackcakes,

Sorry I'm so slow responding to this post. I've been away from this forum for several months. The method I gave only works with desktop printers. If you can set yours up as a desktop printer, then it should work (in theory). I thought there was some technique for setting up a USB printer that way, maybe some printer utility, but I've never done it myself.

Link to comment
Share on other sites

This topic is 7022 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.