Hello,
I would like to open a folder full of Excel spreadsheets, one by one, to save each as a PDF and close it. I’m having trouble locating the right syntax for the core operation and for iterating through the folder. I have two questions therefore:
- What is the proper syntax for “save workbook as MainWkbk filename fName file format PDF”?
- How do I iterate?
Thank you to anyone who can help a new AppleScripter (but not a newcomer to coding). My code:
set textToDisplay to “How many files are in this folder?”
display dialog textToDisplay default answer “3”
set valueEntered to text returned of the result
try
set valueEntered to valueEntered as integer
end try
if class of valueEntered is integer then
repeat valueEntered times
tell application “Finder”
set OpenFolder to choose folder
set OpenFile to open first file in OpenFolder
tell application “Microsoft Excel”
set MainWkbk to active workbook
set fName to string value of MainWkbk & “.pdf”
save workbook as MainWkbk filename fName
close MainWkbk
activate application “Finder”
end tell
end tell
end repeat
else
display dialog “You did not enter a (valid) number.”
end if