• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Microsoft Word Create New Document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Microsoft Word Create New Document


  • Subject: Re: Microsoft Word Create New Document
  • From: Stan Cleveland <email@hidden>
  • Date: Wed, 07 Dec 2016 15:06:08 -0800

On Dec 7, 2016, at 02:33 PM, Gil Dawson <email@hidden> wrote:
Thanks for your suggestion.  I was hopeful that it might work, but no.  Same error, same place (my emphasis):

set TargetFile to (path to desktop) & "TestFileName"
tell application "Microsoft Word"

--    These work:
--create new document  
--set ReportDoc to the active document
--    These do not work:
--set ReportDoc to create new document
set ReportDoc to make new document
save as ReportDoc file name TargetFile
insert text ("Some text" & return) at end of text object of active document
set ReportText to text object of ReportDoc
--> Microsoft Word got an error: The object you are trying to access does not exist
tell ReportText to insert text ("Some text" & return) at end
save ReportDoc
close ReportDoc
end tell

There's also a note from Script Debugger, "Invalid Object Reference"

Hi Gil,

It seems that the reference to ReportDoc disappears once the document is saved. So you'll need to refer to the document by name from then on. Something like this:

set TargetName to "TestFileName"
set TargetFolder to "" & (path to desktop)
tell application "Microsoft Word"
set ReportDoc to make new document
save as ReportDoc file name TargetFolder & TargetName
tell document TargetName
insert text ("Some text" & return) at end of text object
set ReportText to text object
tell ReportText to insert text ("Some text" & return) at end
save
close
end tell
end tell

Maybe that will move things forward with your project.

Regards,
Stan C.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Thanks! Re: Microsoft Word Create New Document
      • From: Gil Dawson <email@hidden>
References: 
 >Microsoft Word Create New Document (From: Gil Dawson <email@hidden>)
 >Re: Microsoft Word Create New Document (From: Stan Cleveland <email@hidden>)
 >Re: Microsoft Word Create New Document (From: Gil Dawson <email@hidden>)

  • Prev by Date: Re: Script to Activate Different Monitor Profile Depending on Frontmost Application ??
  • Next by Date: Re: Microsoft Word Create New Document
  • Previous by thread: Re: Microsoft Word Create New Document
  • Next by thread: Thanks! Re: Microsoft Word Create New Document
  • Index(es):
    • Date
    • Thread