I’m at the start of a huge learning curve with Applescript and feel way out of my depth. I’m sure what I’m trying to achieve is possible but I don’t know how to go about it.
I am trying to create a Droplet that will convert Word documents into pdf files and save them into a designated folder, not the same folder as the Word documents. Seems straightforward enough.
Google showed me a script that will save pdfs into the same folder as the Word documents but that’s not what I require and I don’t know how to change it.
Another problem is the script only works with straight forward Word documents. By that I mean the files I’m working with all have multiple links to external data in an Excel workbook. The links are set to automatically update. When the document opens, a prompt appears requiring a response. I don’t know how to write a script that answers the prompt. See image.
All the files open but the script fails at the prompt, so I have to manually click ‘Yes’ for each one.
Ideally the script would answer ‘Yes’ (not ‘No’) to the prompt for each file in the list and then save a pdf into my designated folder before closing.
Another problem. The automatic update setting, triggers another prompt on closing the document, asking if I want to save changes or not; ideally yes. I don’t know how to write a script to answer this prompt either.
Turning the ‘Update: automatically’ option on and off gets around the prompts but it’s not really a viable solution. In short, I looking for a Droplet that can answer both prompts appropriately and also save a pdf to my designated folder.
You said you wanted to use AppleScript and you implied that you have a partially working script want to make changes to it. I wouldn't be able to help you with AppleScript (others here probably could) but if you want to use Keyboard Maestro I could probably help you (but bear in mind that I don't have Word.) In order for me to help you use KM, I need to know the exact set of steps you take when you do this process manually. I'm good at automating manual steps, but in this case I know very little about the steps you are taking, outside of the two dialog boxes you showed above. One thing that could simplify the process, if you want to try it, is create a video showing all the steps that you take manually for a single file. With that I could probably draft a KM macro for you.
But if you want to use AppleScript instead, that's fine. We can wait for someone who knows AppleScript to assist. I think they would want to see the script that you have up to this point.
Let me leave you with a snippet of code that might help you with the second dialog box above.
tell application "Finder"
set input to selection
end tell
tell application id "com.microsoft.Word"
activate
set view type of view of active window to draft view
repeat with aFile in input
open aFile
set theOutputPath to ((aFile as text) & ".pdf")
repeat while not (active document is not missing value)
delay 0.5
end repeat
set activeDoc to active document
save as activeDoc file name theOutputPath file format format PDF
close active document saving no
end repeat
end tell
If you want an AppleScript solution, we have to wait for someone else to help. If you want a KM solution, I might be able to convert the above to KM. I'm looking at it now to see if I can figure out how to convert it.
Roughly, very roughly, the KM code will look something like this:
The outer loop appears to be the KM action required to loop for each filename selected in the Finder. Each Comment indicates the action that KM may require at that point in the loop. It's hard for me to fill in the real code because the AppleScript code you provided does not appear to correlate to the Menu Item Names in the MS Word application. Also, you may need to insert the code that I showed you earlier in order to wait for a button and press it.
That appears to be the gist of it. Do you want to wait for an AppleScript wizard, or do you want to try writing the KM code with my help? You will need to tell me exactly what you would click on in the MS Word app in order to get me to write the KM code.
Great. I truly have no idea whatsoever whether people will help you with a non-KM problem when you don't have KM. I really don't. They might. But since you are pursuing ALYB on another site, let us know what ALYB says here in this thread.
I see, it's the same website, just a different thread. He just hasn't responded in months, so you reposted on a new thread. That's fair, I guess. Did you try sending him a message on this website? If you do, I think he gets an email, which might get his attention faster.