How can I locate each tab in my documents and replace them with spaces?

K

Ken Wan

Hi,
I am converting my word documents into another file format. One task is to
locate all tabs in word documents and replace them with spaces according to
tab stop setting. Any suggestions will be greatly appreciated.
Ken
 
H

Helmut Weber

Hi Ken,
the first step could be this:
Dim sL As Single 'left border of tab
Dim sR As Single 'right border of tab
Dim sW As Single 'width of tab
Selection.WholeStory
Selection.Collapse
With Selection.Find
.Text = "^t"
While .Execute
Selection.Collapse
sL = Selection.Information(5) 'left border
.Execute
Selection.Collapse direction:=wdCollapseEnd
sR = Selection.Information(5)' right border
sW = sR - sL
MsgBox sW ' width
.Execute
Wend
End With
The question now is, how would you like to translate
e.g. 12.75 points into space characters? I think,
theoretically and exactly, this is impossible.
Nevertheless you my find a good enough working compromise.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
W

Word Heretic

G'day "Ken Wan" <[email protected]>,

Find and replace vbtab with " "

Ken Wan said:
Hi,
I am converting my word documents into another file format. One task is to
locate all tabs in word documents and replace them with spaces according to
tab stop setting. Any suggestions will be greatly appreciated.
Ken

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 

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