Script to add a Template for MS Word

Mac OS 10.8 (Mountain Lion), Applescript Editor 2.5.1 and Microsoft Word for Mac 2011.

I got the below script from http://word.mvps.org/mac/applescript-vba.html. But the script not compiling. What’s going wrong. Why (do Visual Basic) Command not supporting for me?


tell application "Microsoft Word"
        do Visual Basic "Documents.Open \"Macintosh Hard Disk:Applications:Microsoft Office X:Templates:My Templates:Special Template.dot\"
         Application.Run \"Module1.MyProcedure\""
end tell

I have to add a Word Template i.e., “Test.dot” from one particular path and to run a “For_Test” Macro from that Template in an active document. Can anyone help me.

Hi there,

I’ve had a quick look at the dictionary, for Word 2011, and it looks like ‘do Visual Basic’ isn’t there.
If I replace it with ‘do script’ that line compiles.

It looks like the script you’ve found might be for an earlier version of Word.

Can you work forward from the final script here?

http://macscripter.net/viewtopic.php?id=43846

Hi TecNik,

Thanks for your reply.

If I replace “do visual basic” with “do script” it compiles, but not working.

Its the post posted by me. I can able to run the macro by the following way.

run VB macro macro name "Normal.NewMacros.MyMacro"

I want to know the AS for MS Word syntax to add a template from server.

e.g.,

"Macintosh HD:users:username:XXX:xxxxxx.dot"

Thanks,
John

Hi John,

Re

Are you wanting to copy a .dot file from a server? If so, you could simply get the Finder to copy the template file to the required folder.

Hi TecNik,

Thanks for your reply.

No, I not want to copy a file from server to somewhere.

I like to add a Template (.dot) file i.e., (Word Menu/Tools/Template and Add-Ins) - Add (Choose a template to add)

Thanks,
John

Maybe I’m a bit late in replying, but the syntax you need is

tell application "Microsoft Word" 
   add addin file name (pathVar & msWordTemplateLocation) with install
end tell

where pathVar is the path to the home folder and msWordTemplateLocation is the path to the Word template, i.e. Library:Application Support:Microsoft:Office:User Templates:template_name.dotm

That will work in Word 2011.