• 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: Strange Word behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange Word behaviour


  • Subject: Re: Strange Word behaviour
  • From: David Crowe <email@hidden>
  • Date: Tue, 19 Feb 2019 13:14:06 -0700

My biggest problem is that Word appears to completely ignore the “whose name
is” clause.

tell application "Microsoft Word"
        set l1 to first document
        set l2 to name of first document
        set l3 to name of first document whose name contains
"supercalifragilisticexpialidocious"
end tell

name of l1 & "," & l2 & "," & l3

I have three files open, and the last line prints “Test 1.docx” three times.
Secondarily it decides what “first” is (nothing to do with what’s in front).

But if I could say, “first document whose name is “Test 2.docx” I wouldn’t have
to worry about order because there would only be one result.


But the workaround was to pick up the list of all documents, and then loop
through looking for the one I wanted.

- David



> Date: Tue, 19 Feb 2019 03:53:55 -0600
> From: Christopher Stone <email@hidden>
> To: Applescript Users List <email@hidden>
> Subject: Re: Strange Word behaviour
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="utf-8"
>
> On 02/16/2019, at 17:24, David Crowe <email@hidden
> <mailto:email@hidden>> wrote:
>> Am I doing something wrong, or is Word (Word 2011) just broken?
>
>
> Hey David,
>
> Well – Microsoft Word is Microsoft Word...  :)
>
> If you know your document exists you could do something like this:
>
> ----------------------------------------------------------------
>
> tell application "Microsoft Word"
>    set theDoc to first item of (get documents whose name is "Zebra.docx")
> end tell
>
> ----------------------------------------------------------------
>
> But a better general strategy would be to do something like this:
>
> ----------------------------------------------------------------
>
> tell application "Microsoft Word"
>
>    set docList to documents whose name is "Zebra.docx"
>
>    if length of docList = 1 then
>        set theDoc to item 1 of docList
>    end if
>
> end tell
>
> ----------------------------------------------------------------
>
> Don't forget that saved Word documents include the file suffix in the file
> name.
>
> --
> Best Regards,
> Chris
>

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

 _______________________________________________
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:
    • Re: Strange Word behaviour
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: Strange Word behaviour
  • Next by Date: Re: Strange Word behaviour
  • Previous by thread: Re: Strange Word behaviour
  • Next by thread: Re: Strange Word behaviour
  • Index(es):
    • Date
    • Thread