I’m trying to get a script running that will open all the InDesign 2.0 files in a folder and export them to PDF. I seem to be having problems with the export function. Script Editor gives me “Syntax Error: Expected class name but found application constant or consideration” and highlites “PDF type” in my code. Here is a test script that I am using to try and pin down what is going wrong. Any help would be much appreciated.
--Set InDesign as the object receiving our messages
tell application "InDesign 2.0"
--Create a new document and assign its
--identity to the variable "myDocument"
set myDocument to make document
--attempt to export to PDF using "screen" setting
tell myDocument
export as PDF type to "Mike's Drive:myExportedPDF.pdf" using pdf export style "Screen" showing options false
end tell
end tell
Sorry i do not have Indesign but
it sounds like In design may be having trouble recognising the PDF type command check the applications dictionary to verify you have it right
I figured it out…sort of. Now for the next step. The syntax in the scripting guide was actually wrong and after messing with it for a bit, I came up with this:
tell application "InDesign 2.0"
--This is where the PDF logic goes
tell application "InDesign 2.0"
--Create a new document and assign its
--identity to the variable "myDocument"
set myDocument to make document
tell myDocument
--attempt to export to PDF using "screen" setting
export format PDF type to myPDFFolder using PDF export style "Screen" without showing options
end tell
end tell
end tell
Well, we just moved to InDesign CS and it seems to no longer work with my old script. Here is the old script in its entirety:
--Choose style type
set stylelist to choose from list {"[85 dpi - network send]", "[100 dpi - network send]", "[100 dpi - kinkos]", "[150 dpi - kinkos]", "[200 dpi - kinkos]", "[300 dpi - high quality inhouse print]"} with prompt "Select PDF Export Style"
set mystyle to item 1 of stylelist
set myFolder to choose folder with prompt "Select folder containing InDesign Documents"
set myFileList to {}
--set mystyle to choose from list {"85 dpi - network send", "150 dpi - kinkos"}
tell application "Finder"
set myFiles to files of myFolder
repeat with myFileCounter from 1 to (count myFiles)
if file type of item myFileCounter of myFiles is "InDd" then
copy (item myFileCounter of myFiles) as string to end of myFileList
end if
end repeat
end tell
if (count myFileList) > 0 then
set myPDFFolder to choose folder name with prompt "Save PDF files to:"
--This is where the PDF logic goes
repeat with thisItem in myFileList
tell application "InDesign 2.0.2"
open file thisItem
set thisItem to active document
tell active document
--attempt to export to PDF using user defined setting
set PDFname to myPDFFolder & the name of thisItem & ".pdf" as string
try
export format PDF type to PDFname using mystyle --with showing options
end try
end tell
close active document
end tell
end repeat
else
display dialog "No InDesign files were found in the selected folder."
end if
For some reason, InDesign CS’s PDF export options have changed again. Everything in the old script works with a simple filetype change (make inDd into IDd3) save the export command. Grabbing the new InDesign scripting guide yeilded more incorrect syntax. I can’t even get a basic example script for the ID CS Scripting Guide to compile. Anyone have any ideas?