Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, October 29, 2014 7:40 AM
Hi everyone,
I convert a lot of documents from PDF into Word and find that often this process can leave up to four spaces between each word in a sentence (where normally there should only be one!)
Example:
There are too many spaces between words here! ! !
Is there any way I can create a Macro to run or is there any readily available function in MS Word 2013 that will adjust this problem for me?
...Up until now I have been amending these little errors myself and as you can imagine on a 20 page document, this is extremely time consuming. Help very much appreciated!
Thanks,
FP
All replies (4)
Wednesday, October 29, 2014 3:29 PM ✅Answered
Manually, you could enter ^w in the 'Find what' box of the Replace dialog, and a single space in the 'Replace with' box, then click 'Replace All'.
As a macro:
Sub ReduceSpaces()
Application.ScreenUpdating = False
With ActiveDocument.Content.Find
.ClearFormatting
.Text = "^w"
.Replacement.ClearFormatting
.Replacement.Text = " "
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com)
Thursday, October 30, 2014 7:05 AM ✅Answered
Hi,
Based on my test, we don’t need to create a macro to remove multiple spaces between words in Word.
We can use Find and replace function to remove extra spaces. In Find and Replace dialog, click More button and then Check the Use wildcards box. In Find what textbox and then type ( ){2,}. In Replace what textbox and then type \1.
Note: there is a space between ().
More information about Find and replace text or other items:
Best regards,
Greta Ge
TechNet Community Support
It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.
Friday, November 4, 2016 2:49 PM
Hi Hans,
This has been working excellently - thank you for your help. However, recently I have been formatting with some tabs and noticed that when I use this macro to get of excess spaces the tabs are deleted also! How can I use this for both keeping tabs but deleting the excess spaces? Is there a workaround?
Friday, November 4, 2016 3:46 PM
Using ^w finds all white space, i.e. any combination of tabs and spaces. To find multiple spaces only:
Sub ReduceSpaces()
Application.ScreenUpdating = False
With ActiveDocument.Content.Find
.ClearFormatting
.Text = " {2,}"
.Replacement.ClearFormatting
.Replacement.Text = " "
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com)