Save embedded Word Doc as PDF
Well, I will be damned!
Thanks Pradeep for your suggestion. Seems like the application that you were referring to is obsolete with new MAC versions. So I searched the MAC Store and found another application called SMILE.
I tested the original script in in SMILE. There was nothing wrong with it and it worked perfectly!!!
set pdfSavePath to "Users:siddharth:Documents:Sid.pdf"set theDocFile to choose file with prompt "Please select a Word document file:"tell application "Microsoft Word" open theDocFile set theActiveDoc to the active document save as theActiveDoc file format format PDF file name pdfSavePathend tell
So I tried the code which I was testing earlier and to my surprise, it worked this time without me making any change to the original code!!! So I am stumped on what could be the problem... Did Smile
install something which made the script work in Excel? Guess I will never find out.
Option ExplicitSub tester() Dim scriptToRun As String scriptToRun = "set pdfSavePath to " & Chr(34) & "Users:siddharth:Documents:Sid.pdf" & Chr(34) & Chr(13) scriptToRun = scriptToRun & "set theDocFile to choose file with prompt " & Chr(34) & "Please select a Word document file:" & Chr(34) & Chr(13) scriptToRun = scriptToRun & "tell application " & Chr(34) & "Microsoft Word" & Chr(34) & Chr(13) scriptToRun = scriptToRun & "open theDocFile" & Chr(13) scriptToRun = scriptToRun & "set theActiveDoc to the active document" & Chr(13) scriptToRun = scriptToRun & "save as theActiveDoc file format format PDF file name pdfSavePath" & Chr(13) scriptToRun = scriptToRun & "end tell" & Chr(13) Debug.Print scriptToRun Result = MacScript(scriptToRun) MsgBox ResultEnd Sub
SMILE SNAPSHOT
EDIT: FOUND THE ERROR
On closer inspection, I found that my original script had an extra line. I was setting the PDF path twice. Can be seen in the snapshot.