Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete text between strings (Word 2003)

    How can I search for 2 different text strings and then delete the text between the strings? I want to repeat this several times in a document.
    I don't know much about VBA. I can record a macro to search for the first string and then search for the second string but I don't see how to select the text between the strings so I can delete it.

    Thanks

    Hymer

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

    Re: Delete text between strings (Word 2003)

    Let's say that you want to delete the text between the strings "quick brown fox" and "lazy dog" wherever it occurs in the document.

    Select Edit | Replace...
    Click More >>.
    Tick the check box "Use wildcards".
    In the 'Find what' box, enter

    (quick brown fox)(*)(lazy dog)

    The * is a wildcard, standing for any number of characters. The parentheses divide the search text into three parts that can be referred to in the 'Replace with' box as 1, 2 and 3. We want to delete the middle part, so enter the following in the 'Replace with' box:

    13

    Click 'Replace All'. If you don't like the result, you can undo the action.

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete text between strings (Word 2003)

    Hans

    That's just what I needed. It works perfectly and is much simpler than I had thought it would be.

    Thanks very very much.

    Jim

Posting Permissions

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