Hi all,
Back again with what is presumably an easy question, but I did some searches and found nothing.
I edit documentation. I have reason to execute dozens of search and replaces in nearly every doc I work on as a means to make corrections, so it makes sense to save time and write these searches into a macro.
The following is code that was generated when I recorded a search and replace action using the Record Macro feature built into Word. It obviously executes a single search and replace - "Word A" for "Word B".
I know that to run several search and replaces one after another, all I'd need to do is essentially copy this code several times. But this is likely too much code – is there a more efficient way to execute many, many search and replaces? Maybe a way to store terms to a matrix or range and execute a search and replace based on that? Some of my search terms would require case sensitivity, and some would require finding whole word instances, but I think getting around this proublem would be as easy as grouping terms based on search requirements, right?Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "Word A" .Replacement.Text = "Word B" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll
If there's an efficient way to go about this, I'd do hundreds, maybe even thousands of search and replaces. See, I created an AutoCorrect with over 12,000 corrections (Word ships with about 960), so I'd likely load up those entries into this macro. I suppose if you guys can help me, I'd host the file somewhere for you guys to download. If you're interested, of course.
So, any ideas? I'm running Windows 7 and Office 2010, btw, if it makes any difference.
Thanks in advance!!