CleanUpPastedText()


Joined
May 16, 2018
Messages
1
Reaction score
0
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
.ClearFormatting
.Replacement.ClearFormatting
.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.
 
Ad

Advertisements

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
503
Reaction score
46
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)?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top