I get an error in the first if - then statement. I cannot seem to get the syntax right.
the tell block does for MSWord, does not seem to save the file - the script hangs and I think this is where. The logic flow seems ok, but again, I am struggling with syntax.
Thanks for your help.
tell application “System Events”
set pN to name of (some process whose visible is true and frontmost is true)
tell process pN to keystroke “c” using {command down}
end tell
if (exists ((path to documents folder as text) & “huddle.doc”)) then
tell application “Finder” to delete ((path to documents folder as text) & “huddle.doc”)
end if
tell application “Microsoft Word”
activate
delay 2
if not (exists document 1) then
make new document
end if
set left margin of page setup of document 1 to (inches to points inches 0.5)
set top margin of page setup of document 1 to (inches to points inches 0.5)
set right margin of page setup of document 1 to (inches to points inches 0.5)
set bottom margin of page setup of document 1 to (inches to points inches 0.5)
set header distance of page setup of document 1 to (inches to points inches 0)
set footer distance of page setup of document 1 to (inches to points inches 0)
paste special text object of document 1 data type paste text
tell text object of document 1 to set font size of font object to 12.0
auto format text range text object of document 1
save document 1 in ((path to documents folder as text) & “huddle.doc”)
delay 2
quit
end tell
set the_file to ((path to documents folder as text) & “huddle.doc”)
set the_subject to “Huddle”
tell application “Mail”
set new_message to make new outgoing message with properties {subject:the_subject, content:“Thought For The Day”, visible:true}
tell new_message
make new to recipient at end with properties {address:“lbennett@mdoyledds.com”}
make new attachment at end of first paragraph of content with properties {file name:the_file as alias}
end tell
end tell