Tabstops problem

M

Mike Turner

In a document there are 5 tabstops in each (one-line)
paragraph and the tabstops are same for each.

Is there a way of saying,for example, "insert text at the
4th tabstop position"?

At present I enter text by using,eg

ActiveDocument.Content.InsertAfter "This is text"

I move from one tab position to the next by using :

ActiveDocument.Content.InsertAfter vbTab

(in other words,"tab to next tab position")

but this can break down-for instance,if text is entered
at the first tabstop position,doing a "tab to next
position" twice will take one to the 3rd tabstop position
if the text at the first tabstop position did not cross
over past 2nd position,but to the 4th position if the
text did cross over past the 2nd tabstop position.

Thus I am looking for a way of inserting text at a
specific tab position which does not rely on where cursor
is at present.

Thanks very much for any helpurner
 
M

Mike Turner

Thanks very much Jay

Mike

-----Original Message-----
Hi, Mike,

You can use this subroutine:

Private Sub TabToNthStop(WhichStop As Integer)
Dim pos4thStop As Single

With Selection
.Collapse wdCollapseEnd
pos4thStop = .ParagraphFormat. _
TabStops(WhichStop).Position

Do While .Information( _
wdHorizontalPositionRelativeToTextBoundary) _
< pos4thStop
.InsertAfter vbTab
.Collapse wdCollapseEnd
Loop
End With
End Sub

Call it from your main procedure like this:

Selection.InsertAfter "This is text"
Selection.EndKey unit:=wdStory
TabToNthStop WhichStop:=4

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word




.
 

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

Similar Threads


Top