Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-09-2018, 11:53 AM
David Matthews David Matthews is offline Macro to remove spaces between characters Windows 7 64bit Macro to remove spaces between characters Office 2016
Novice
Macro to remove spaces between characters
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to remove spaces between characters How to remove blank spaces between rows in a table, Jamal NUMAN Word 2 04-28-2017 12:59 PM
A Widlcard or Macro to Properly Remove Spaces Between Commas? CrossReach Word 6 01-23-2017 04:28 AM
Can I remove spaces between only Chinese characters? sivartnosredna7 Word 2 01-09-2017 05:33 AM
How to remove spaces from Cells which are at the end of value? LearnerExcel Excel 2 12-19-2016 01:10 PM
editing text and remove spaces romanticbiro Word VBA 5 07-04-2014 07:42 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft