InDesign: script PS export.. changing printer styles = FUBAR

Howdy all! I’m doing more on a script to export each page as a separete PS file from InDesign CS/2.0.2. There is no entry in the library to retrieve a list of printer styles, it is sometimes necessary for me to manually select one from the pulldown in the print dialog box.

This seems to do some serious evil to the apple events still pending in the script, even though there are no specific settings. Here is the following code:

set isFirstPage to yes
tell application "InDesign CS"
-- documentToUse is an INDD file selected by the user	
set pagelist to name of pages in document named documentToUse
			set pagestoprint to (choose from list pagelist with prompt ("Choose pages to print") with multiple selections allowed)
			repeat with i from 1 to (the number of items in pagestoprint)
					tell document named documentToUse
						tell print preferences
							set printer to postscript file
-- prints out each PS file with the page number appended to the user-chosen docName
set print file to (pathToDisk & docName & "_" & item i of pagestoprint & ".ps")
							set page range to item i of pagestoprint as text
						end tell
-- check here to put the dialog box up on the first one, but not on any of the other pages					
if isFirstPage = yes then
							print with print dialog
							set isFirstPage to no
							print print dialog no
						end if
					end tell
				on error
					display dialog ("An error occured while printing page " & item i)
				end try
			end repeat
		end tell

This is working perfect if the user doesnt mess with the print style pulldown. If they do, its game over. Any thoughts on what I can do to get around this?

thanks so much,

I don’t have CS, but this is no problem in 2. Has something changed?

Check out the preferences classes.

printer styles class can give you a list of printer styles.
you can create/define your own styles.
You can set the active printer style

In the print command in the standard suite, you can print using

This works for me.

Thank you thank you thank you thank you! :smiley:

This did the trick. Thanks again.