(I posted this to the FileMaker forums last week since it is kind of FileMaker specific, but not getting much input there so thought I’d try here!)
We’ve been exporting data and using it for merging in Word for years, all nicely automated via Filemaker & AppleScript. Click a button, FMP exports and triggers an AppleScript to open the master document in Word and perform the merge. Every time there’s a big OS release, something breaks and has to be fixed. This time I have to fix it (I know, just now trying to get to Mavericks, shame on me). I thought I had it figured out–I have a script that works in AppleScript Editor but when I insert it into a Filemaker Pro 13 script it doesn’t work.
It seems to be getting hung up in the stage where it has to click pop ups to finish opening the master document in Word. It’s like Filemaker is ignoring the ‘ignoring application responses’ part (which is the only way I was able to get AppleScript Editor to continue with clicking the elements in the window, something about Mavericks and Word 2011 means that when it pops up a dialog during the open process the script doesn’t seem to realize it can keep going). If I click through the dialog myself, I get an error message in Filemaker when it then proceeds and tries to click them for me but is unable to. (I have enabled the Accessibility option for FMP, so it should be able to click the buttons. It’s not giving me an error that it’s not allowed.)
Here’s the AppleScript:
run application "Microsoft Word" ignoring application responses tell application "Microsoft Word" activate open file name "Volumes:LAS Documents:Lion_Production:Corp Certificates:corpcerts2.docx" with read only end tell end ignoring tell application "System Events" tell process "Microsoft Word" delay 1 set frontmost to true click pop up button 2 of window 1 click menu item "|" click pop up button 1 of window 1 click menu item "~" click button 2 of window 1 end tell end tell tell application "Microsoft Word" delay 2 execute data merge data merge of document "corpcerts2.docx" close document "corpcerts2.docx" saving no end tell
Any advice is welcome. I’m pretty green when it comes to AppleScript, so the fact that I’ve gotten this far is pretty much a miracle.