• 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: Christopher Stone <email@hidden>
  • Date: Wed, 20 Feb 2019 02:03:07 -0600

On 02/19/2019, at 14:14, David Crowe <email@hidden
<mailto:email@hidden>> wrote:
> My biggest problem is that Word appears to completely ignore the “whose name
> is” clause.


Hey David,

No, it doesn't.

As Shane explained there're peculiarities in how Word handles first.

Word seems to see only launch order and NOT index order.

This works perfectly fine:

----------------------------------------------------------------

tell application "Microsoft Word"
    set docList to documents whose name contains "Fahrenheit"
end tell

-->

{
    document "Fahrenheit 451.docx" of application "Microsoft Word",
    document "Fahrenheit.docx" of application "Microsoft Word"
}

----------------------------------------------------------------

There's no need to loop through all documents when filtering works.

But – keep in mind that you're messing around with documents here – and
documents generally have no concept of index order.

To get window indexes you need to work with windows.

Unfortunately Word 2011 doesn't track window indexes...

If you need to do this then the simplest thing is to resort to System Events:

----------------------------------------------------------------

tell application "System Events"
    tell application process "Microsoft Word"
        set myDoc to first window whose subrole is "AXStandardWindow" and name
contains "Fahrenheit"
    end tell
end tell

----------------------------------------------------------------

tell application "System Events"
    tell application process "Microsoft Word"
        try
            set myDocName to name of first window whose subrole is
"AXStandardWindow" and name contains "Fahrenheit"
        on error
            set myDocName to "NULL"
        end try
    end tell
end tell

if myDocName ≠ "NULL" then
    tell application "Microsoft Word"
        set myDoc to document myDocName
    end tell
end if

----------------------------------------------------------------

--
Take Care,
Chris



 _______________________________________________
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

References: 
 >Re: Strange Word behaviour (From: David Crowe <email@hidden>)

  • Prev by Date: Re: Strange Word behaviour
  • Next by Date: Newbie Question: Changing Applescripts from Interarchy to Transmit
  • Previous by thread: Re: Strange Word behaviour
  • Next by thread: Re: Strange Word behaviour
  • Index(es):
    • Date
    • Thread