Re: Some Hope For MS Word Accessibility
Re: Some Hope For MS Word Accessibility
- Subject: Re: Some Hope For MS Word Accessibility
- From: Don Urquhart <email@hidden>
- Date: Fri, 24 Oct 2014 21:20:16 -0700
Tried copying your snippet for building a versatile text range, no go. Error now says “Can’t get content of missing value”. Word version is Word for Mac 2011 V 14.0.0
> On Oct 24, 2014, at 5:08 AM, Axel Luttgens <email@hidden> wrote:
>
> Le 23 oct. 2014 à 05:09, Don Urquhart a écrit :
>
>> Dear All,
>> [...]
>>
>> — Select a line of text, then tell VoiceOver to speak it
>> tell application "Microsoft Word"
>> tell application "System Events"
>> tell process "Microsoft Word" to key code 123 using {command down}
>> delay 0.5
>> tell process "Microsoft Word" to key code 124 using {shift down, command down}
>> delay 0.5
>> end tell
>> set theText to get content of text object of selection
>> end tell
>> tell application "VoiceOver" to output theText
>>
>> [...]
>>
>> Dreaming aside, can you recommend a better scripting reference for Word, or a better method than key sending to select text? If so, I’ll grab the ball and run with it. Thanks in advance :-)
>
> Hello Don,
>
> It seems you may achieve the above without SE:
>
> tell application "Microsoft Word"
> tell front window
> tell text object of selection
> select text object of first paragraph
> set theText to content
> end tell
> end tell
> end tell
>
> On the other hand, Word's dictionary also provides commands such as "move start of range", "move range end until", and so on. But they seem to interact with the selection itself, in quite a strange way; for example, moving the selection's end appears to collapse the selection as well... (this is with Word 2011).
>
> However, this may be circumvented; for example, for extending the selection towards the end of the paragraph:
>
> tell application "Microsoft Word"
> tell selection
> set s to selection start
> tell text object to move end of range by a paragraph item count 1
> set selection start to s
> set theText to content
> end tell
> end tell
>
> Now, it may prove more versatile to build a text range, which is then liable to be re-used for several consecutive operations, without being affected by those start/end interactions:
>
> tell application "Microsoft Word"
>
> -- Build a text range similar to, but independent of, the selection.
> tell front window to set {s, e} to selection's {selection start, selection end}
> set r to set range of text object of active document start s end e
>
> -- Extend the range to the end of current paragraph
> set r to move end of range r by a paragraph item count 1
> set theText to content of r
>
> end tell
>
> HTH,
> Axel
>
>
>
> _______________________________________________
> 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
_______________________________________________
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