Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Search in Word using VBA (Word xp)

    I'm trying to search for all the instances of a 3 line combination. The first line is just a paragraph marker ^p, the 2nd line is a sentence, the 3rd line is another parag markert. All 3 lines are in styles, Heading 3. I want the middle (2nd) sentence to remain in heading 3 and the empty ^p above and below the sentence to be deleted. When i delete the one below the sentence the heading 3 style disappears also. Thank you for the help.

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Search in Word using VBA (Word xp)

    Someone might come up with a single search and replace to do this but I would use a pretty big hammer and just do a search and replace on ^p^p and replace with ^p

    This would get rid of all empty paragraphs (except single ones in and around tables).

    Is it important to retain the empty paragraphs not in the Heading 3 style?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Search in Word using VBA (Word xp)

    > When i delete the one below the sentence the heading 3 style disappears also.

    It disappears from the paragraph containing the sentence? That doesn't sound right. How are you deleting it?

  4. #4
    New Lounger
    Join Date
    May 2001
    Location
    Blackpool, Lancashire, England
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search in Word using VBA (Word xp)

    I've come across similar but can't recollect how it happens. I'm sure its something to do with the 'styles' settings/definition. Like the 1st suggestion, a workaround would be to reapply the style in code directly after the delete and while the cursor/selection is in the text of the paragraph concerned. (selection.style ="????")

Posting Permissions

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