I’m trying to create a script that will open a template that has my company’s letterhead, copy the header and footer, then insert the header and footer into the document I’m working on, then, ideally, insert a picture of my signature and print to pdf.
Here’s what I’ve got, that isn’t working. Any ideas?
tell application "Finder"
activate
select Finder window 1
open document file "letterheadtemplate.dotx" of folder "My Templates" of folder "User Templates" of folder "Office" of folder "Microsoft" of folder "Application Support" of folder "Library" of folder "Chip" of folder "Users" of startup disk
end tell
tell application "Microsoft Word" to activate
tell application "System Events"
tell application process "Microsoft Word"
keystroke "7" using {command down} --I've defined a system-wide keyboard shortcut for "Header and Footer" to make this work, because I couldn't figure out the command in Word to select the header.
keystroke "a" using {control down} --I've also done this for select all because I defined a different command for cmd-A
keystroke "c" using {command down}
end tell
tell application "Microsoft Word" to activate
tell application "System Events"
tell application process "Microsoft Word"
keystroke "`" using {command down} --switch to other window in Word
keystroke "7" using {command down}
keystroke "a" using {control down}
keystroke "v" using {command down}
end tell
end tell