Add tab stop for *rest of section*

R

Rick

[moved thread from Word.PageLayout...]:

I've learned that to add a tab stop at 4" to the current section I do
this:

Dim oRg As Range
Set oRg = Selection.Sections(1).Range
oRg.Paragraphs.TabStops.Add Position:=InchesToPoints(4),
Alignment:=wdAlignTabLeft

Suppose later on in the section I realize that for the remainder of
the section (current insertion point onward) I need to clear the tab
stop I just set above (while leaving the text above my current
insertion point formatted according to that tab stop), and then add a
tab stop to take effect only from my current position till the rest of
the section?

I'm probably not thinking this through correctly as my 4" tab stop
really isn't for the entire section, but the 'range' for which I
really want to set that tab stop isn't easily defined. (I know I'm
thinking in terms of 'position' rather than objects...)

Any help would be appreciated.
 
J

Jean-Guy Marcil

Rick said:
[moved thread from Word.PageLayout...]:

I've learned that to add a tab stop at 4" to the current section I do
this:

Dim oRg As Range
Set oRg = Selection.Sections(1).Range
oRg.Paragraphs.TabStops.Add Position:=InchesToPoints(4),
Alignment:=wdAlignTabLeft

Suppose later on in the section I realize that for the remainder of
the section (current insertion point onward) I need to clear the tab
stop I just set above (while leaving the text above my current
insertion point formatted according to that tab stop), and then add a
tab stop to take effect only from my current position till the rest of
the section?

Try this:

Dim oRg As Range

With Selection.Range
Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)
End With

With oRg.Paragraphs.TabStops
.ClearAll
.Add Position:=InchesToPoints(2), Alignment:=wdAlignTabLeft
End With
 
R

Rick

That works perfectly. Thank you.

I want to make sure I understand it. When you do

Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)

you are using Range method which takes two args -- starting character
position and ending character position? And ".Start" references the
current insertion point, which becomes the first argument (start
position)?

And for the second argument (end position) you use "Sections
(1).Range.End", which is how you reference the end of the current
section? You're getting the .End property of the .Range property of
the current section, and then you feed that as the second arg to the
Range method?




[moved thread from Word.PageLayout...]:
I've learned that to add a tab stop at 4" to the current section I do
this:
Dim oRg As Range
Set oRg = Selection.Sections(1).Range
oRg.Paragraphs.TabStops.Add Position:=InchesToPoints(4),
Alignment:=wdAlignTabLeft
Suppose later on in the section I realize that for the remainder of
the section (current insertion point onward) I need to clear the tab
stop I just set above (while leaving the text above my current
insertion point formatted according to that tab stop), and then add a
tab stop to take effect only from my current position till the rest of
the section?

Try this:

Dim oRg As Range

With Selection.Range
    Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)
End With

With oRg.Paragraphs.TabStops
    .ClearAll
    .Add Position:=InchesToPoints(2), Alignment:=wdAlignTabLeft
End With

--
______________________________
Jean-Guy Marcil
Montreal, Canada- Hide quoted text -

- Show quoted text -
 
J

Jay Freedman

Everything you've written is correct.

I just want to be sure you understand one point of syntax. Whenever you see an
expression that starts with a dot, such as .Start or .Sections(1) in the code
below, that refers to a property or method of some object that was specified by
a "With" statement somewhere in the preceding lines. In this case, they're both
properties of Selection.Range because of the line

With Selection.Range

If you try to write an expression that starts with a dot but you fail to supply
the With statement, you'll get a compile error, "Invalid or unqualified
reference".

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

That works perfectly. Thank you.

I want to make sure I understand it. When you do

Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)

you are using Range method which takes two args -- starting character
position and ending character position? And ".Start" references the
current insertion point, which becomes the first argument (start
position)?

And for the second argument (end position) you use "Sections
(1).Range.End", which is how you reference the end of the current
section? You're getting the .End property of the .Range property of
the current section, and then you feed that as the second arg to the
Range method?




[moved thread from Word.PageLayout...]:
I've learned that to add a tab stop at 4" to the current section I do
this:
Dim oRg As Range
Set oRg = Selection.Sections(1).Range
oRg.Paragraphs.TabStops.Add Position:=InchesToPoints(4),
Alignment:=wdAlignTabLeft
Suppose later on in the section I realize that for the remainder of
the section (current insertion point onward) I need to clear the tab
stop I just set above (while leaving the text above my current
insertion point formatted according to that tab stop), and then add a
tab stop to take effect only from my current position till the rest of
the section?

Try this:

Dim oRg As Range

With Selection.Range
    Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)
End With

With oRg.Paragraphs.TabStops
    .ClearAll
    .Add Position:=InchesToPoints(2), Alignment:=wdAlignTabLeft
End With

--
______________________________
Jean-Guy Marcil
Montreal, Canada- Hide quoted text -

- Show quoted text -
 
R

Rick

Thank you; all this help (both practical and
theoretical) has been much appreciated.

Everything you've written is correct.

I just want to be sure you understand one point of syntax. Whenever you see an
expression that starts with a dot, such as .Start or .Sections(1) in the code
below, that refers to a property or method of some object that was specified by
a "With" statement somewhere in the preceding lines. In this case, they're both
properties of Selection.Range because of the line

With Selection.Range

If you try to write an expression that starts with a dot but you fail to supply
the With statement, you'll get a compile error, "Invalid or unqualified
reference".

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

That works perfectly. Thank you.

I want to make sure I understand it. When you do

Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)

you are using Range method which takes two args -- starting character
position and ending character position? And ".Start" references the
current insertion point, which becomes the first argument (start
position)?

And for the second argument (end position) you use "Sections
(1).Range.End", which is how you reference the end of the current
section? You're getting the .End property of the .Range property of
the current section, and then you feed that as the second arg to the
Range method?




[moved thread from Word.PageLayout...]:

I've learned that to add a tab stop at 4" to the current section I do
this:

Dim oRg As Range
Set oRg = Selection.Sections(1).Range
oRg.Paragraphs.TabStops.Add Position:=InchesToPoints(4),
Alignment:=wdAlignTabLeft

Suppose later on in the section I realize that for the remainder of
the section (current insertion point onward) I need to clear the tab
stop I just set above (while leaving the text above my current
insertion point formatted according to that tab stop), and then add a
tab stop to take effect only from my current position till the rest of
the section?

Try this:

Dim oRg As Range

With Selection.Range
    Set oRg = ActiveDocument.Range(.Start, .Sections(1).Range.End)
End With

With oRg.Paragraphs.TabStops
    .ClearAll
    .Add Position:=InchesToPoints(2), Alignment:=wdAlignTabLeft
End With

--
______________________________
Jean-Guy Marcil
Montreal, Canada- Hide quoted text -

- Show quoted text -
 

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