View Single Post
Old 06-29-2005, 08:46 AM   #4
vsp
Syndrome of a Down
 
Join Date: Jun 2001
Location: West Chester
Posts: 1,367
I have everything I need working pretty well in Word 2000, functioning properly almost 100% of the time with proper input.

Naturally, someone tested my code in Word 2002 today, and it fails completely. Bafflingly, Word 2002 seems unable to handle basic Find/Replace functionality that I recorded using Record A Macro in Word 2000.

Here's a sample chunk of code that's failing:
Code:
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("Block Label")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindAsk
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    Do While .Execute
      (Text manipulation goes here)
    
' End and repeat the loop until all Units in the doc are done
   Loop
   End With
   Selection.EndKey Unit:=wdStory
This is NOT complicated stuff. Move up in the document, find Block Label style, twiddle it, then find the next place it appears and repeat the process.

In Word 2002, the Find _fails_. I've checked the styles on the structures, and they're perfect. I click the icon for my macro and it scans through the document, doesn't find _any_ instances of Block Label <b>even though I can SEE several of them on any given page</b>, and coughs and dies.

Is there something about using Find to find text in tables in Word 2002 that I really need to know?

(For reference, it's not the loop that's failing. The debugger is pointing to the Find statement itself and returning a "Not found in document" error, and my versions that do them one at a time without looping fail the same way.)
vsp is offline   Reply With Quote