R
Roger Morris
MS Office 11.2.3 and Mac OS 10.4.5
I have many Word documents for which I want to change the attached
template and thought this might be easy to do using Applescript.
This script (testing with just one doc) fails:
----------------------------------
set theTplate to ((choose file with prompt "Template")) as string)
set theDoc to ((choose file with prompt "Document") as string)
tell application "Microsoft Word"
open document file name theDoc
do Visual Basic "ActiveDocument.AttachedTemplate:=\"" & theTplate & "\""
close document theDoc saving yes
end tell
----------------------------------
BUT after the selected document opens:
A message box appears with :
Compile error: / Syntax error
and the VB editor code window contains:
----------------------------------
Sub TmpDDE()
ActiveDocument.AttachedTemplate:="Aragorn:Users:rmesktop:aTemplate"
End Sub
----------------------------------
(with 1st line arrowed in LH margin, 2nd line highlighted)
It matters not whether the template is in
~/Desktop or
~/Documents/Microsoft User Data/Templates/My Templates
I believe the "do VB" bit came from a post by Paul Berkowitz although
now I can't find it again so can't give a reference.
Can anyone tell me what is wrong please?
Roger
I have many Word documents for which I want to change the attached
template and thought this might be easy to do using Applescript.
This script (testing with just one doc) fails:
----------------------------------
set theTplate to ((choose file with prompt "Template")) as string)
set theDoc to ((choose file with prompt "Document") as string)
tell application "Microsoft Word"
open document file name theDoc
do Visual Basic "ActiveDocument.AttachedTemplate:=\"" & theTplate & "\""
close document theDoc saving yes
end tell
----------------------------------
BUT after the selected document opens:
A message box appears with :
Compile error: / Syntax error
and the VB editor code window contains:
----------------------------------
Sub TmpDDE()
ActiveDocument.AttachedTemplate:="Aragorn:Users:rmesktop:aTemplate"
End Sub
----------------------------------
(with 1st line arrowed in LH margin, 2nd line highlighted)
It matters not whether the template is in
~/Desktop or
~/Documents/Microsoft User Data/Templates/My Templates
I believe the "do VB" bit came from a post by Paul Berkowitz although
now I can't find it again so can't give a reference.
Can anyone tell me what is wrong please?
Roger