Results 1 to 7 of 7

Thread: Solved: Help with Search and Replace faulty code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Nov 2012
    Posts
    37
    Location

    Solved: Help with Search and Replace faulty code

    Hi,

    I'm running this code without success:

    [vba]
    Sub RemoveCaptionFields()
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .text = "Figure ^d STYLEREF 1 \s ^21-^d SEQ Figure \* ARABIC \s 1 ^21: "
    .Replacement.text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    End With
    End Sub
    [/vba]
    What I'm trying to do is remove all the "Figure { chapter number }-{ page number }: " in the figure captions of a document.

    The funny thing is that if I use Word's Search and Replace function to look for that string, it finds it. But if I click "Replace all" (using an empty Replace field), it says it could not find a single occurrence of the string.

    Any help will be highly appreciated!

    Daniel
    Last edited by bcn; 07-02-2013 at 05:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •