• 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: MS Word 2004 basic questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MS Word 2004 basic questions


  • Subject: Re: MS Word 2004 basic questions
  • From: kai <email@hidden>
  • Date: Wed, 7 Feb 2007 15:49:47 +0000


On 7 Feb 2007, at 14:01, some blabbermouth wrote:

On 2 Feb 2007, at 22:49, email@hidden wrote:

Is there a way I could get the whole word that the selection is part of?

Something like this should do it:

That was a bit more convoluted than it needed to be. Take 2:

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

set search_text to text returned of (display dialog "Enter the text to find:" default answer "")

tell application "Microsoft Word"

set selection's selection end to 0
set selFind to find object of selection
set selFind's content to search_text
set text_found to execute find selFind
if not text_found then return beep (* signal failure *)

tell (create range active document start 0 end selection's selection end)
set word_count to count words
set word_start to end of content of words 1 thru (word_count - 1)
set word_end to end of content of words 1 thru word_count
set found_word to set range it start word_start end word_end
end tell

content of found_word

end tell


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

---
kai


_______________________________________________ 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/mailman//archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: MS Word 2004 basic questions
      • From: Larry the O <email@hidden>
References: 
 >MS Word 2004 basic questions (From: email@hidden)
 >Re: MS Word 2004 basic questions (From: kai <email@hidden>)

  • Prev by Date: RE: 'Using Terms From ...' Question
  • Next by Date: Re: Re: Applescript and Mouse Keys failure
  • Previous by thread: Re: MS Word 2004 basic questions
  • Next by thread: Re: MS Word 2004 basic questions
  • Index(es):
    • Date
    • Thread