Delete leading tab character in a selection

R

Raul

I have to modifiy a number of documents that were formatted by someone who
formatted the documents using the tab character hundreds of times.

I'm using find and replace in some code to eliminate most of the tabs, and
that is working to a point. The next step is to learn how to find and
replace the first tab in a line only if it the first thing in the line (i.e.,
it is not preceeded by any letter).

Any help will be greatly appreciated.

Thanks in advance,
Raul
 
G

Graham Mayor

Select the text (CTRL+A)
The CTRL+E (centre)
then CTRL+L (left align) to remove all the leading spaces and tabs

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Raul

That will work for me.

Thanks,
Raul

Graham Mayor said:
Select the text (CTRL+A)
The CTRL+E (centre)
then CTRL+L (left align) to remove all the leading spaces and tabs

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Steve C

Graham,

What is needed to make these steps work in programming? If I record a macro
while performing these steps, I get the following:

Selection.WholeStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft

However, when run, this doesn't remove the leading tab. Thanks for any help
you can give me.
 
D

Doug Robbins - Word MVP

Use:

With ActiveDocument.Range.ParagraphFormat
.Alignment = wdAlignParagraphLeft
.LeftIndent = 0
.FirstLineIndent = 0
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
S

Steve C

Doug,

Thanks for the reply. I tried that, but the tabs remained. As a
workaround, I came up with this (although I'm sure it's not the most
efficient):

LineCount = ActiveDocument.Paragraphs.Count 'counts total # of lines in
document

For x = 1 To LineCount
Selection.Delete Unit:=wdCharacter, Count:=1 'removes tab character
Selection.MoveDown Unit:=wdLine, Count:=1
Next x
 

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