I frequently strip leading/trailing spaces from text using:
Ctrl+A
Align Center
Align Left
I recorded a macro of these same steps which reads:
Sub strip()
Selection.WholeStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End Sub
But when executed, all it does is Select All and stops, as if there are no
other commands, leaving the text selected.
Does anyone know how to accomplish these three steps in VBA?
wordproc - 23 Mar 2005 01:55 GMT
I obtained the answer from another forum and have posted it here for anyone
else who may need this bit of information:
Selection.WholeStory
Application.CommandBars("Formatting").Controls("Center").Execute
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Notice the difference between the "Center" command line and the
"wdAlignParagraphLeft" command line.
> I frequently strip leading/trailing spaces from text using:
>
[quoted text clipped - 14 lines]
>
> Does anyone know how to accomplish these three steps in VBA?