on process_item(this_item)
tell application “Microsoft Word”
activate
open this_item
do Visual Basic " Application.Run MacroName:=“Normal.NewMacros.Macro7"”
do Visual Basic " Application.Run MacroName:=“Normal.Format_PDN_Patient_Name.Format_PDN_Patient_Name”"
do Visual Basic " Application.Run MacroName:=“Normal.Fix_JBS.JBSFinal”"
close document 1 of window 1
end tell
end process_item
I would like this to run in the background and don’t know how to get it to do so. Many times I have to process 30-50 documents with this script, and would like to be doing something else while it’s running.
I would appreciate any help as I’m still fairly new to AppleScript :oops:
The activate command simply tells an application to come to the front (it will also launch an app that isn’t running). I don’t have Word but I don’t see anything in the script that requires Word to be frontmost.
All the “activate” command does is bring the application to the foreground. Now, like Rob mentions, removing the activate command is a good start. But, you will still see it in the background doing stuff. And if you are doing other things, you may accidentally interrupt it. I haven’t done much scripting with Word, but some apps like to be in the foreground for certain tasks.
Another thing to try is to tell the appliction to “hide”. Usually, that will let the app keep doing its thing, but you won’t see the windows, and that will help keep you from clicking on document accidentally.
Maybe Word demands that it be the frontmost application. It wouldn’t surprise me.
Does this work?
on process_item(this_item)
tell application "Microsoft Word"
set open_doc to open this_item
do Visual Basic "Application.Run MacroName:="Normal.NewMacros.Macro7""
do Visual Basic "Application.Run MacroName:="Normal.Format_PDN_Patient_Name.Format_PDN_Patient_Name""
do Visual Basic "Application.Run MacroName:="Normal.Fix_JBS.JBSFinal""
close open_doc
end tell
end process_item