• 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: Some Hope For MS Word Accessibility
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some Hope For MS Word Accessibility


  • Subject: Re: Some Hope For MS Word Accessibility
  • From: Axel Luttgens <email@hidden>
  • Date: Fri, 24 Oct 2014 14:08:25 +0200

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


  • Follow-Ups:
    • Re: Some Hope For MS Word Accessibility
      • From: Don Urquhart <email@hidden>
    • Re: Some Hope For MS Word Accessibility
      • From: Don Urquhart <email@hidden>
    • Re: Some Hope For MS Word Accessibility
      • From: Don Urquhart <email@hidden>
References: 
 >Some Hope For MS Word Accessibility (From: Don Urquhart <email@hidden>)

  • Prev by Date: Re: Yosemite toolbars [Was: Yosemite Script Editor replies pane]
  • Next by Date: Re: Some Hope For MS Word Accessibility
  • Previous by thread: Some Hope For MS Word Accessibility
  • Next by thread: Re: Some Hope For MS Word Accessibility
  • Index(es):
    • Date
    • Thread