• 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: Find and Replace in Word 2008
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find and Replace in Word 2008


  • Subject: Re: Find and Replace in Word 2008
  • From: Matt Deatherage <email@hidden>
  • Date: Mon, 21 Jan 2008 12:23:09 -0600

On 1/21/08 at 4:39 AM, Michael Ghilissen <email@hidden> wrote:

This works for me. I omitted the clear formatting statement.

I have one that's more specific in my macros that I rewrote for Word 2008 a week or two ago (in a completely optimistic but ultimately misplaced belief that MDJ could say something intelligent about Office 2008 before Macworld Expo), and it's working for me:

---

on replace_all(theSource, theReplacement)
tell application "Microsoft Word"
set myFindObject to find object of text object of active document
clear formatting myFindObject
clear formatting replacement of myFindObject
set resultExecuteFindResult to execute find myFindObject ¬
find text theSource ¬
match case true ¬
match whole word false ¬
match wildcards false ¬
match sounds like false ¬
match all word forms false ¬
match forward true ¬
wrap find find continue ¬
find format false ¬
replace with theReplacement ¬
replace replace all
end tell
end replace_all


---

I could make myFindObject the subject of a "tell" block, but for initial
work, this syntax seemed a bit clearer to me, since I'd then have to use
"of it" in several places. Also, note that my find object is from the
text object of the active document, not "of paragraph 4" or something
else that may cause problems if you try to use the routine in general.
making it "find object of text object of selection" should also work.


Plus, in case it hasn't been said (sorry, I have to skim programming
lists during news crunch times), MacTech's April 2007 "Office VBA to
AppleScript Transition Guide" can be tremendously helpful. If you have
the issue, dig it out. If not, read it online here:


<http://www.mactech.com/vba-transition-guide/>

...or buy a PDF of it and a MacTech subscription for just $10. I'll bet
it will save you time.


--Matt
--
Matt Deatherage                              <email@hidden>
GCSF, Incorporated                      <http://www.macjournals.com>

"Patriotism is supporting your country all the time, and your government
 when it deserves it."  -- Mark Twain



_______________________________________________
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: Find and Replace in Word 2008 (From: Michael Ghilissen <email@hidden>)

  • Prev by Date: Re: Can't get finder selection
  • Next by Date: A Tutorial on AppleScripting a mySQL Database
  • Previous by thread: Re: Find and Replace in Word 2008
  • Next by thread: How to parse CSV
  • Index(es):
    • Date
    • Thread