• Macro with conditions (Any)

    Author
    Topic
    #430338

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #1004479

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

      If you do need a macro, here is the code equivalent of the above:

      Sub Test()
      Selection.HomeKey Unit:=wdStory
      With Selection.Find
      .MatchWildcards = True
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "([!.^13])^13"
      .Replacement.Text = "1 "
      .Execute Replace:=wdReplaceAll
      End With
      End Sub

    Viewing 0 reply threads
    Reply To: Macro with conditions (Any)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: