Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Macro with conditions (Any)

    I need to create a macro to find all "hard returns" - paragraph characters ( ^p ) and replace them with white spaces ( ^w ) if previous character is not a dot ( . ) or paragraph character ( ^p ).

    Can anybody help me?

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

    Re: Macro with conditions (Any)

    You don't really need a macro for this. You can turn on 'Use wildcards' in the Replace dialog, enter <code>([!.^13])^13</code> in the 'Find what' box and enter <code>1</code> followed by a space in the Replace with box.

    If you do need a macro, here is the code equivalent of the above:
    <code>
    Sub Test()
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
    .MatchWildcards = True
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "(<!t>[!.^13]<!/t>)^13"
    .Replacement.Text = "1 "
    .Execute Replace:=wdReplaceAll
    End With
    End Sub</code>

  3. #3
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro with conditions (Any)

    It works! Thank you!

Posting Permissions

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