Discussion in 'Word' started by Manny Valdez, May 16, 2018.

  1. Manny Valdez

    Manny Valdez

    May 16, 2018
    Likes Received:
    I will appreciate your help to fix the error with this code. I used to run the macro without problem working on Word 2007, but working on Word 2016 I got this problem.

    When I run the macro, it shows me the run time error 5560.

    This is the macro:

    Sub CleanUpPastedText()
    With Selection.Find
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    .Text = "([!^13])([^13])([!^13])"
    .Replacement.Text = "\1 \3"
    .Execute Replace:=wdReplaceAll
    .Text = "([ ])[ ]{1,}"
    .Replacement.Text = "\1"
    .Execute Replace:=wdReplaceAll
    .Text = "[!^13]{2,}"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
    .Text = "[!^13]"
    .Execute Replace:=wdReplaceAll
    End With

    End Sub

    Thank you very much in advance folks.
    Manny Valdez, May 16, 2018
    1. Advertisements

  2. Manny Valdez

    macropod Microsoft MVP

    Mar 2, 2012
    Likes Received:
    That looks like code I wrote. There is nothing about it that would cause a run-time error - it runs fine on my system.

    Have you tried repairing the Office installation (via Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change > Repair)?
    macropod, May 16, 2018
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.