View Single Post
 
Old 05-09-2018, 11:53 AM
David Matthews David Matthews is offline Windows 7 64bit Office 2016
Novice
 
Join Date: May 2018
Posts: 6
David Matthews is on a distinguished road
Default Macro to remove spaces between characters

Hi all,

Been Googling this for the last couple of days and have come up with nothing--nada!

My problem is this: I have a document that contains about 75% of the words with spaces between the characters like the image attached. Crazy, eh? Well, it certainly begs the question, "how the heck did that happen?" What I have learned from my research is sometimes this can occur in PDF to Word conversions and vice versa.

As it's about 150 pages long you can imagine how long it would take to manually take out all the spaces, even with find and replace.

Soooooo, I'm looking for a macro that will remove the single spaces between the characters (I can manually remove the doubles between the words with F&R).

This is what I've developed so far:

Sub RemoveSpaces()
'
' RemoveSpaces Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^? ^?"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub

However i can't get it to loop.

Please advise.

Thank you,

David Matthews (not the band )
Attached Images
File Type: png screenshot.png (40.1 KB, 40 views)
Reply With Quote