Delete leading spaces

  • Thread starter Budget Programmer
  • Start date
B

Budget Programmer

Hello,
I have a 3 column table that is produced for me (I have no control over this
part). THe problem is that it produces leading blanks (1 or 2) in column 1.
I can select various cells within the table, but I can't figure out how to
ensure that I'm always starting on the left, and that I'm eliminating leading
spaces.
Many Thanks.
 
J

Jean-Guy Marcil

Budget Programmer was telling us:
Budget Programmer nous racontait que :
Hello,
I have a 3 column table that is produced for me (I have no control
over this part). THe problem is that it produces leading blanks (1
or 2) in column 1. I can select various cells within the table, but I
can't figure out how to ensure that I'm always starting on the left,
and that I'm eliminating leading spaces.
Many Thanks.

A fast way to eliminate leading spaces is to select the column, set the
alignment to Center, then back to what it was before. (If it is already set
to Center, set to Left, then back to Center)

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

Budget Programmer

Jean-Guy,
Thiw worked when I did it "manually" in word. But I can't get it to work in
a Macro. I'm using the method:

' Select the column
Selection.Columns(lngCurrentColumn).Select
' Center Justify
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
' Left Justify (this should delete leading blanks)
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft

It executes OK. When I step through the code, I can see the column center
justified, but when the next step is executed, it keeps the original leading
space. Again, it works great when I do it "manually" in the word client.

Thanks for your help.
 
J

Jean-Guy Marcil

Budget Programmer was telling us:
Budget Programmer nous racontait que :
Jean-Guy,
Thiw worked when I did it "manually" in word. But I can't get it to
work in a Macro. I'm using the method:

' Select the column
Selection.Columns(lngCurrentColumn).Select
' Center Justify
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
' Left Justify (this should delete leading blanks)
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft

It executes OK. When I step through the code, I can see the column
center justified, but when the next step is executed, it keeps the
original leading space. Again, it works great when I do it
"manually" in the word client.

Ah, right, in this case, try this (Note that you have to select the text
first)

Application.CommandBars("Formatting").Controls("Center").Execute
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft



--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top