Indesign Save As

Hi, I’m trying to work out how to perform a Save As command in Indesign CS2. I’m currently using the save command and giving my file a name, I’m then printing from the file but after this I would like to resave the file as a different file name and print it again. I’ve looked through some help files and it seems as though I can save the file again but if it already has a name it will not give me the save dialog box just save the file using the current name. Any ideas? I’ve attached my script for reference.
Thanks

on open thefile
	set x to thefile as alias
	tell application "Finder"
		set pagetype to display dialog "Select page type" buttons {"Full Page", "DPS"}
		set theanswer to button returned of pagetype
		if theanswer is "Full Page" then
			tell application "Adobe InDesign CS2"
				activate
				set myDocument to make document
				tell document preferences of myDocument
					set page height to "403mm"
					set page width to "298mm"
					set page orientation to portrait
					set pages per document to 1
				end tell
				tell page 1 of document 1
					make guide with properties {orientation:vertical, location:"0mm", guide color:red}
					set myRectangle to make rectangle with properties {geometric bounds:{-3, -3, 406, 301}, stroke weight:0}
					tell myRectangle
						place x
						fit x given center content
					end tell
				end tell
				set MyWindow to active window
				tell MyWindow
					zoom given fit page
				end tell
				tell application "Finder"
					activate
					set thequestion to display dialog "Is the advert content the  correct size and centered?" buttons {"Yes", "No"}
					set userresponse to button returned of thequestion
					if userresponse is "Yes" then
						tell application "Adobe InDesign CS2"
							tell active document to save
							print active document using "TWEK_to_Mosaic_PDF"
							tell active document to save
							tell active document to close
						end tell
					end if
				end tell
			end tell
		else if theanswer is "DPS" then
			
			tell application "Adobe InDesign CS2"
				activate
				set myDocument to make document
				tell document preferences of myDocument
					set page height to "403mm"
					set page width to "298mm"
					set page orientation to portrait
					set pages per document to 3
				end tell
				tell page 2 of document 1
					make guide with properties {orientation:vertical, location:"0mm", guide color:red}
					set myRectangle to make rectangle with properties {geometric bounds:{-3, -3, 406, 599}, stroke weight:0}
					tell myRectangle
						place x
						fit x given center content
					end tell
				end tell
				set active spread of window 1 to parent of page 2 of document 1
				
				set MyWindow to active window
				tell MyWindow
					zoom given fit page
				end tell
				tell application "Finder"
					activate
					set thequestion to display dialog "Is the advert content the  correct size and centered?" buttons {"Yes", "No"}
					set userresponse to button returned of thequestion
					if userresponse is "Yes" then
						tell application "Adobe InDesign CS2"
							tell active document to save
							print active document using "TWEK_to_Mosaic_PDF"
							if saved of active document is false then
								tell active document to save
							end if
							tell active document to save
						end tell
					end if
				end tell
			end tell
		end if
	end tell
end open

Something like this :

save myDocument to (thePath & "TestSaveDoc.indd")

This is fine if the file name is going to be the same each time but unfortunately I would want to use a different filename each time I use the script.

How do you want the file name to change from the original? You could set the new name as a user defined variable using a display dialog. Another would be to set a variable to the current name and change it in some predefined way:

set DocName to name of document 1
save myDocument to (thePath & DocName & "_Printed")

If I have a document that is a spread I want to save the document with a filename eg “abcd-jun-15-06-p001” then print page 1 of the spread. Once this page is printed I would then resave the document with eg “abcd-jun-15-06-p002” and then print page 2 of the spread. When I look in the dictionary it appears that Indesign will allow me to save the document again but rather than giving me the save window, because the file already has a filename it just saves the current document with the existing name.

This works on my computer, two copies of the document saved to the desktop:

set OldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set ThePath to path to desktop as string

tell application "InDesign CS"
	set DocName to name of document 1
	set DocName to text item 1 of DocName as string
	repeat with i from 1 to 2
		save document 1 to (ThePath & DocName & i)
	end repeat
end tell
set AppleScript's text item delimiters to OldDelim
return ThePath

Why save p001 and p002 and not printing from the same document, first p001 end after that p002 with a differtent (print) name?

Hi Jerome,
Thanks for your reply. I’ve tried your script and can see that it will indeed save two copies of the file to my desktop. The problem I have is that the system that I’m printing to is looking for specific file names hence why I need the save dialog window to appear.

Hi JanGeerling,
Thanks also for your reply, I was not sure what you meant by your reply, but If you meant that I could print a PostScript file and then I will be prompted for a name then because of the system/device that I’m printing to this is not possible and I need to print to an output device with a specific naming convention.

Hi Blend,

No, that’s not what I meant (sorry for my bad English …)

What I meant was: why saving the document and not just first print page 1 (and name him x) and after that print page 2 (and name him y).
You don’t have to save your document again just for giving the printed file a different name …

I was not aware that I was able to change the name of a print job other than if I specify printing the file as PostScript rather than to an output device. If this is possible then this sounds good.

Adjust the code for in your own script, but it looks like this:


tell application "InDesign CS"
	tell active document
		set PresetExists to exists printer preset "MyPreset" --check if preset exists
		if PresetExists is false then
			make printer preset with properties {name:"MyPreset"} -- makes printer preset if not existing
		end if
		set thisAreMyPrinterPresets to printer preset "ScriptInstelling"
		tell thisAreMyPrinterPresets
			set print file to (pathOfFile & NameOfFile)
		end tell
		set PrintPrefs to print preferences of documentnaam
		tell PrintPrefs
			set page range to PageName -- this is for wich page you are printing
			set active printer preset to thisAreMyPrinterPresets
		end tell
		print page without print dialog
	end tell
end tell

Hi Jan,
I’ve tried using that script but it keeps giving me an error "“Adobe InDesign CS2 got an error: Can’t get printer preset "TWEK_to_Mosaic_PDF" of active document.” not sure whats wrong!

tell application "Adobe InDesign CS2"
	activate
	tell active document
		set thisAreMyPrinterPresets to printer preset "TWEK_to_Mosaic_PDF" -- this is the name of the preset I want to use
		tell thisAreMyPrinterPresets
			set print file to (pathOfFile & NameOfFile)
		end tell
		set PrintPrefs to print preferences of documentnaam
		tell PrintPrefs
			set page range to PageName -- this is for wich page you are printing
			set active printer preset to thisAreMyPrinterPresets
		end tell
		print page without print dialog
	end tell
end tell

Try it like this :


tell application "Adobe InDesign CS2"
   activate
   tell active document
       set PresetExists to exists printer preset "TWEK_to_Mosaic_PDF" --check if preset exists
       if PresetExists is false then
           make printer preset with properties {name:"TWEK_to_Mosaic_PDF"} -- makes printer preset if not existing
       end if
       set thisAreMyPrinterPresets to printer preset "TWEK_to_Mosaic_PDF"
       tell thisAreMyPrinterPresets
           set print file to (pathOfFile & NameOfFile)
       end tell
       set PrintPrefs to print preferences of documentnaam
       tell PrintPrefs
           set page range to PageName -- this is for wich page you are printing
           set active printer preset to thisAreMyPrinterPresets
       end tell
       print page without print dialog
   end tell
end tell

I did not test this, it’s part of a larger script I use for printing postscriptfiles from In Design. Just to put you on the right track. Also look in Script Editor to the script preferences of In Design (how do you call that in English, in Dutch it’s “Woordenboek”). You stil have to put the correct pagenumber variable in ‘PageName’, the pathOfFile (were you want to print the file to and NameOfFile (that’s the name of file). So you have to put a ‘repeat’ handler, wich looks at the number of pages, and print the pages 1 for 1 with each a different PageName (for your page range) and a different filename. A good book for starting scripting In Design is from Shirley Hopkins (AppleScipting InDesign). Good luck!

Thanks for all your help, I’m getting very close now. One last thing do you know a way of getting Indesign to view a specific page. In my script I’m using

					set active spread of window 1 to parent of page 2 of document 1

But this will only view the left hand page of the spread 2 (page2) but the second time that I print the document I want the right hand page of the spread to view (page3) and I can’t seem to find a way of making this page view.
Thanks again

You must script pages and not spreads (see script example)


tell application "Adobe InDesign CS2"
      set pageCount to (count of pages in document 1) 
      repeat with teller from 1 to pageCount
            set pageName to name of page teller
      end repeat
end tell

I understand that I need to script the page but can you tell me how I tell Indesign that I want to view page 3.
Thanks

remove the - if teller is 3 … end if - statement if you want all the pages in the document printed 1 by 1


tell application "Adobe InDesign CS2"
     activate
     tell active document
          set PresetExists to exists printer preset "TWEK_to_Mosaic_PDF" --check if preset exists
          if PresetExists is false then
               make printer preset with properties {name:"TWEK_to_Mosaic_PDF"} -- makes printer preset if not existing
          end if
          repeat with teller from 1 to pageCount
               set pageName to name of page teller
               if teller is 3 then
                    set thisAreMyPrinterPresets to printer preset "TWEK_to_Mosaic_PDF"
                    tell thisAreMyPrinterPresets
                    set NameOfFile to ("page" & (teller as string)) as string
                    set print file to (pathOfFile & NameOfFile)
               end tell
               set PrintPrefs to print preferences of documentnaam
               tell PrintPrefs
                    set page range to PageName -- this is for wich page you are printing
                    set active printer preset to thisAreMyPrinterPresets
               end tell
               print page without print dialog
          end if
     end tell
end tell

Thats great, Thanks for all your help :smiley:

Not sure if you have everything working. I tried one of the scripts above and got errors on the print presets, even when I made one that had the specified name. Anyway to show the page in the window adjust the code below to your script:


tell application "Adobe InDesign CS2"
	set PageCount to (count of pages in document 1)
	tell document 1
		set WindowProps to properties of layout window 1
		repeat with teller from 1 to PageCount
			set active page of layout window 1 to page teller
			display dialog teller
		end repeat
	end tell
end tell

Note that I am addressing the layout window of document 1 so there is not a chance for it to accidently send the commands to a story editor window and that I am just setting the active page and letting ID set the active spread as needed based on the new page.

This was the final part of the puzzle and now its fixed. Thanks so much, this was really bugging me. Unfortunately for you I’ll know who to ask next time :wink: