Select Printer

Hello there,

Is to possible to use applescript to choose a printer from chooser??

I had written a script that would generate a quark document in quark. However everytime when I want to print this quark document using applescript, it will print it to the wrong printer, or actually it is printing to the printer that is currently selected.

Manually before I exceute this quark applescript, i would need to goto chooser and select the correct printer.
e.g. I would need to goto chooser, pick on the correct zone, say “Zone A” and goto pick on LaserWriter and then select the printer , say “HP8001” (just highlight this printer and exit chooser)

Is it possible for me to add a script in front of my quark script, to tell application Finder to select that particular printer before it goes onto the quark bits??

Hope someone can help me out here, as it is getting annoying and wasting paper.
Many Thanks, Appreciate this.

Cheers

cloudair

I don’t know of a way to do it without a scripting addition.

The Choose Printer command from the XCMD Osax works quite well.

You can check it out here… http://osaxen.com/xcmd.html

Please give an example of what the code would look like. I’ve tried everything and I always get the error:

Finder got an error: Some parameter is missing for Choose Printer

Here’s what I’ve tried:

tell app "Finder"
    Choose Printer PrinterName "MyPrinter"
end tell

and

tell app "Finder"
    Choose Printer DriverName "MyDriver" [PrinterName "MyPrinter"]
end tell

Thanks for any help.

I figured it out…

tell app "Finder"
    Choose Printer DriverName "Laserwriter 8" PrinterName "MyPrinter" Zone "Ethernet"
end tell

The Zone parameter is optional.

If this relies on an osax, the following should work Finder-free:

Choose Printer DriverName "Laserwriter 8" PrinterName "MyPrinter" Zone "Ethernet"

I have very good luck with the choose printer command. I do run into occasional problems where printers fall off the network, or run out of paper, or the occasional PS error but that is due more to the crummy printers we have.

I did have a minor problem getting the printer to switch initially. I used the following code to make sure it was switched before proceeding. Maybe it will help someone out.

set blnPrinterFound to "False" --set this to false initially
set intTimesTried to 0 --use this to keep track of how many times we've tried
repeat until blnPrinterFound = "True"
	try
		Choose Printer DriverName "LaserWriter 8" PrinterName "HP LaserJet 2200" Zone "SOME_ZONE"
		set blnPrinterFound to "True" --if the last line does not fail, set this to true
	on error
		
		set intTimesTried to intTimesTried + 1 --if it fails, keep track of how many times we've tried
		if intTimesTried = 100 then --if it reaches 100, do something
			--email someone and move on, or quit
     exit repeat
		end if
	end try
end repeat

L8er,

When I try:

Choose Printer DriverName “DJ 800 Series (AT)” PrinterName “DeskJet 855C”

Compile Script highlights the word “Printer” following “Choose” and says:

Expected end of line but found identifier.

I’m a newbie to AppleScript. Just upgraded my PowerComputing clone to OS 9.2.2. Using Multiple Users. I have to run Chooser every time I restart the computer to pick my printer (doesn’t remember my previous choice). So I thought I could Applescript that in my StartUp Items folder.

Sorry,

I forgot to post a link to the scripting addition this command is found under. You will have to download and install XCMD Osax. After the file is downloaded, move the scripting addition to the scripting additions folder in the system folder. If you have your script editor open, close and relauch so the commands are available.

Good luck!