• 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: Word 2008 text range from Message 3 of AppleScript-Users Digest, Vol 7, Issue 88
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Word 2008 text range from Message 3 of AppleScript-Users Digest, Vol 7, Issue 88


  • Subject: Re: Word 2008 text range from Message 3 of AppleScript-Users Digest, Vol 7, Issue 88
  • From: Michael Tompsett <email@hidden>
  • Date: Mon, 08 Feb 2010 00:15:37 +0100

OK, made some progress with this after using the Wildcard feature. The following script allows me to select text between two markers.

The trick was in the correct phrasing of  "set content" line, and also the line setting wildcards to true

CODE:

tell application "Microsoft Word"
  set selection to null
  set selfind to find object of selection
  set forward of selfind to true
  set wrap of selfind to find continue
  set match wildcards to true
  set content of selfind to "($)*(%)"
  execute find selfind
end tell

END CODE

with this sample text: "More then three centuries after the $Flying Scotsman% was brought into service, it looks like the famous name $may be back% in service."

Result is that $Flying Scotsman% is highlighted.

Now that i can do that, it raises another question. In the Word 2008 Find dialog box, if "Highlight all found items in..." is ticked, then it will select all occurrences of the find request in the text body. So in the example text above, both sets of text   $Flying Scotsman%   and   $may be back%   would become highlighted in word, meaning that the style can be changed to italic to both in one go, rather than looping through the document and changing each one individually as I currently am doing.

I was wondering if it is possible to replicate the "Highlight all found items in..." part of the find request in applescript?
I can see nothing in the word 2008 dictionary for it under the find procedure.



On 7 Feb 2010, at 21:00, email@hidden wrote:

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

Message: 3
Date: Sun, 07 Feb 2010 01:23:04 +0100
From: Michael Tompsett <email@hidden>
Subject: Word 2008 text range between markers
To: email@hidden
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Try as I may I just can't figure this one out. In my word document I  
have sections of text which are delimited by a markers. I want to be  
able to italicize the text between the markers. To do this, I presume  
I need to set the text range, or possibly selection, as the text  
between these two markers. And this has got me stumped.

I'm able to find and select the first marker, and then find and select  
the second marker, but how do I then select the text between these two  
markers or set the text as a text range so that further actions can be  
made on it.

Example text is:

"More then three centuries after the $Flying Scotsman% was brought  
into service, it looks like the famous name $may be back% in service."

I want to be able to italicize the text between the markers $ and %,  
so in the example above  "Flying Scotsman" and "may be back" would  
turned into italics

Any help greatly appreciated.

 _______________________________________________
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: Word 2008 text range from Message 3 of AppleScript-Users Digest, Vol 7, Issue 88
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Stuffit Deluxe not applescriptable in 10.6.2
  • Next by Date: Simple problem: duplicate Word doc contents...not so simple
  • Previous by thread: Re: Stuffit Deluxe not applescriptable in 10.6.2
  • Next by thread: Re: Word 2008 text range from Message 3 of AppleScript-Users Digest, Vol 7, Issue 88
  • Index(es):
    • Date
    • Thread