Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

strip leading/trailing spaces

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wordproc - 22 Mar 2005 22:55 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.