Most of my macros revolve around finding particular styles in the document, moving the insertion point to that location and performing actions. I've got the majority of them working just how I want them to work in Word 2000, and all seemed well. Yesterday, I had someone test the template in Word 2002 and several of the macros failed there.
I'd used Record A Macro to record the functions in 2000, so I figured that doing that in 2002 would produce compatible macros for 2002. No dice -- it produced the EXACT SAME CODE. The steps being performed worked fine as they were being recorded in both 2000 and 2002, and in macro form in 2000, but won't work as a macro in 2002.
I narrowed the problem as follows in 2002:
* Typed the word "plotz" in a document. Recorded a macro that would use a CTRL-F Find to find the word "plotz". Ran the macro, success.
* Put the word "plotz" in a table, repeated the above, success, so it's not a table issue.
* Changed the style of the word "plotz" to Heading 6 (a style I don't normally use), hit Record, did a CTRL-F search for "plotz", ran the macro. Success, so searches for specific text are fine.
* Hit Record, did a CTRL-F search for Heading 6 style (no text specified), success. When I ran the macro, however, it failed to find Heading 6 anywhere in the document, and coughed and died when it reached the action following the search.
Sample recorded macro:
Sub FindContinued() ' ' FindContinued Macro ' Macro recorded 6/23/2005 by delfin ' ' Find the Continued Topic style in the document Selection.Find.ClearFormatting Selection.Find.Style = ActiveDocument.Styles("Continued Topic") Selection.Find.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute ' Deselect what is found, and put cursor at beginning of that line Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.HomeKey Unit:=wdLine End Sub
I have a number of macros that use similar Selection.Find.Style functionality, and they're all failing in 2002. I am at a loss as to what to look for in 2002, and have limited testing time in that environment (I'd be taking work time away from coworkers' machines). Thoughts?