Consulting

Results 1 to 6 of 6

Thread: Removing text of a particular style and surrounding spaces

  1. #1
    VBAX Regular
    Joined
    Mar 2021
    Posts
    8
    Location

    Question Removing text of a particular style and surrounding spaces

    I often create word documents that have two different styles of text. Normal style is the actual contents and "MyNotes" style is notes entered inline with the actual content. The notes are added in parenthesis, like the below examples. I would like to delete all content that is in parenthesis and (not or) of the MyNotes style. I would also like to correct the spacing around the removed text (regardless of whether the spaces around the parenthetical are of Normal or MyNotes style), as in the below examples. The corrected spacing would also (ideally) be changed to the normal style, but this isn't a deal breaker.

    Example 1 (italics used to represent the "MyNotes" style):
    Before: The first vehicle (such as a car (2-door or 4-door) or truck) can reach speeds of 150mph.
    After: The first vehicle can reach speeds of 150mph.

    Example 2 (note that "bright" uses the "MyNotes" style, but should not be removed because it is not in parentheticals):
    Before: The toaster has a bright color (that cannot be changed).
    After: The toaster has a bright color.

    Example 3:
    Before: I appreciate your help. (I've spent a few hours but can't figure it out.)
    After: I appreciate your help.

    I would highly appreciate any guidance or particular resources I should review.
    Last edited by SFRandy; 03-14-2021 at 06:20 PM.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    You could use a wildcard Find/Replace, where:
    Find = [^s ]\([!\(]@\)
    Replace = nothing
    and you specify the Find Style.

    To process you first example, the F/R will need to be executed twice.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    Mar 2021
    Posts
    8
    Location
    Thanks! I will try this to see if I can make it work.

  4. #4
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    119
    Location
    If you are not giving out the original but printing or sending to pdf, you could simply change the formatting of your style to Hidden.

  5. #5
    VBAX Regular
    Joined
    Mar 2021
    Posts
    8
    Location
    Thanks, unfortunately, hidden won't work. I'm also aware of the styles option (ctrl-alt-shift-S, then right click on style) to highlight all text of a particular style, then hit "DEL" key to delete it all. This deletes all text of that format, including text not in parenthesis. The select/delete strategy also messes up the formatting (e.g., changes indents and line spacing) for some reason.

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Chas Kenyon View Post
    you could simply change the formatting of your style to Hidden.
    But that would also hide content in that Style not bounded by parentheses, which is not what the OP wants.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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