Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Atlanta
    Posts
    568
    Thanks
    7
    Thanked 1 Time in 1 Post

    Field code in replace (XP)

    I was trying to use Word to write a batch file to rename a number of files and I wanted to name the files using a sequence number. I was able to do everything else but I could not figure out how to use a field code in a search and replace operation. Specifically, I wanted to replace a dash with:

    -{ SEQ Count# "000" * MERGEFORMAT}

    only have Word see this as a dash followed by a field code rather than seeing it as just text. Is this possible?

    Ronny
    Ronny Richardson

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field code in replace (XP)

    Method 1: create one SEQ field manually and copy it to the clipboard.
    Select Edit | Replace...
    Enter <code>-</code> in the Find what box, and <code>-^c</code> in the Replace with box.
    Click Replace All.
    (<code>^c</code> is the 'code' for the contents of the clipboard.

    Method 2: use a macro:

    Sub ReplaceDash()
    Selection.HomeKey wdStory
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "-"
    .Replacement.Text = ""
    .Format = False
    Do While .Execute
    Selection.Collapse wdCollapseEnd
    ActiveDocument.Fields.Add Selection.Range, _
    wdFieldSequence, "Count# ""000"""
    Loop
    End With
    End Sub

Posting Permissions

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