insert tab stop from this point forward

R

Rick

I have text in my document below where my cursor is. How do I create
a tab stop that will be set for the rest of the document forward? I
know if I just enter a tab stop normally, it won't be in effect for
any text below my cursor position. Thanks.
 
J

Jay Freedman

Rick said:
I have text in my document below where my cursor is. How do I create
a tab stop that will be set for the rest of the document forward? I
know if I just enter a tab stop normally, it won't be in effect for
any text below my cursor position. Thanks.

Select all of the text where you want the tab stop to be set (most easily by
pressing Ctrl+Shift+End) and then set the tab stop.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Rick

Thanks; that does it. Is there an easy way to then return to where I
was before pressing Ctrl+Shift+End?
 
R

Rick

Sorry -- I really meant to ask how to do this in VBA code -- should
have posted in the VBA forum...
 
J

Jay Freedman

This is kind of clumsy about getting the tab stop position, and you could
also ask the user for the alignment and leader type, but you get the idea...

Sub SetTabStopToEndOfDoc()
Dim strStop As String
Dim nStop As Single
Dim oRg As Range

strStop = InputBox("Position of tab stop in inches:")
If Len(strStop) > 0 Then
nStop = CSng(Val(strStop))
If nStop > 0 Then
Set oRg = Selection.Range
oRg.End = ActiveDocument.Range.End
oRg.Paragraphs.TabStops.Add _
Position:=InchesToPoints(nStop), _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderSpaces
Set oRg = Nothing
End If
End If
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Rick

Fabulous; thank you. I'm trying to teach myself about
the Range object. How would I set a tab stop for the
current Section only (rather than the rest of the
document)? Do I still use Range for that?
 
J

Jay Freedman

Yes, you can use a Range. Replace the lines

Set oRg = Selection.Range
oRg.End = ActiveDocument.Range.End

with

Set oRg = Selection.Sections(1).Range

This may not make much sense at first sight, but it means "the range of the
first section of which any part is in the Selection". If the Selection is wholly
within one section, then that is the section that will be affected.
 

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