Consulting

Results 1 to 8 of 8

Thread: Find/Delete text in a document

  1. #1

    Find/Delete text in a document

    Hello,

    First. I want to thank the forum. It's really cool what you guys do for us newbies.

    I have a two part question. Not sure if I should post separately, and I will if that makes sense, but I feel they are related.

    So first. I have a block of text:

    I want to keep this.
    I want to delete this.
    I want to keep this.

    The end result would be, and I have no clue how to get it to delete the line in the middle.
    I want to keep this.
    I want to keep this.

    Second:

    I want to keep this.
    IDnumber sometext1
    I want to keep this.
    IDnumber sometext2

    The end result will be:

    I want to keep this.
    I want to keep this.

    For the latter, I imagine it will be a while loop, but I can't figure out how to find the first string and then move to the end, not to mention deleting the resulting line in between. Please assume each line ends in a paragraph break.

    Thank you for any help.

  2. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    1. Format all text as hidden
    2. Use Find/Replace to remove the hidden attribute from:
    I want to keep this.
    3.
    Use Find/Replace to delete all hidden text.

    You could, of course, record the above as a macro.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Hi Paul. Thanks for the quick response. I will try this approach tomorrow. For the second part of my question, this is what my data looks like:
    Picture1.jpg

    So I would need to delete the lines that start with Service Locator until the line ends, after the number. Would the approach above be viable? Thanks again.

  4. #4
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    If all you need to do is delete lines that start with 'Service Locator', all you need is a straightforward wildcard Find/Replace, where:
    Find = ^13Service Locator*^13
    Replace = ^p
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Hi Paul,

    My apologies, but the caret 13 is literal? I used the syntax as above and no results were returned. Thanks.

  6. #6
    Ok. Realized ^sService Locator*^13 would work. Thank you.

  7. #7
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by mellowest View Post
    Realized ^sService Locator*^13 would work.
    That suggests your lines don't start with 'Service Locator', but with a non-breaking space followed by 'Service Locator'.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  8. #8
    Indeed. Thanks for the help.

Posting Permissions

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