|
|
|
|
|
|
Word
|
Eliminate Multiple Spaces
|
|
Ease of Use
|
Easy
|
Version tested with
|
2000
|
Submitted by:
|
lucas
|
Description:
|
Reduces excessive spaces between words to one space
|
Discussion:
|
You have imported text or pasted it into your document or for whatever reason, you have more than one space between a lot of the words. This routine will reduce those excessive spaces to one space.
|
Code:
|
instructions for use
|
Place this code In a standard module:
Option Explicit
Sub EliminateMultipleSpaces()
On Error GoTo ERRORHANDLER
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = " [ ]@([! ])"
.Replacement.Text = " \1"
.MatchWildcards = True
.Wrap = wdFindStop
.Format = False
.Forward = True
.Execute Replace:=wdReplaceAll
End With
With .Find
.Text = "^p "
.Replacement.Text = "^p"
.MatchWildcards = False
.Wrap = wdFindStop
.Format = False
.Forward = True
.Execute Replace:=wdReplaceAll
End With
End With
ERRORHANDLER:
With Selection
.ExtendMode = False
.HomeKey Unit:=wdStory
End With
End Sub
|
How to use:
|
- Open the Visual Basic Editor by going to tools-Macro's-Visual Basic Editor or use Alt-F11
- On the toolbar of the Visual Basic Editor, go to insert - module
- In the module pane paste the code above.
- Close the Visual Basic Editor by clicking the X in the upper right corner or go to File-Close
|
Test the code:
|
- Type a sentence into your document and add extra spaces between the words.
- On the main menu go to tools-macro-macros.
- In the dialog window select EliminateMultipleSpaces and then click run.
- The excessive spaces will be reduced to one space.
|
Sample File:
|
EliminateMultipleSpaces.zip 9.66KB
|
Approved by mdmackillop
|
This entry has been viewed 159 times.
|
|