E
Elessvie
Dear Programmers,
I am stumped about why "oRange" is doing what it is doing and wondered if
someone could explain it to me (and/or point me in the right direction). We
are using Word 2003 and the macro is in VBA. Here is my code (it's from the
very beginning of the macro):
Dim oRange As Range
Set oRange = ActiveDocument.Tables(2).Range
With oRange
'collapse oRange to a point at the end of Table 2:
.Collapse wdCollapseEnd
'insert next-page-section-break right after Table 2:
.InsertBreak wdSectionBreakNextPage
'insert a paragraph right after the section break:
.InsertParagraphAfter
'
'If I understand correctly, the insertion point
'at this point should still be where oRange was
'collapsed--at the end of Table 2.
End With
oRange.Select
With Selection
.TypeText "TOC"
End With
'
' But here, "TOC" appears right after
' the inserted paragraph, not right
' after Table 2. Isn't oRange now still
' just a point after Table 2?
Any feedback greatly appreciated.
Thanks so much!
-Lynne
I am stumped about why "oRange" is doing what it is doing and wondered if
someone could explain it to me (and/or point me in the right direction). We
are using Word 2003 and the macro is in VBA. Here is my code (it's from the
very beginning of the macro):
Dim oRange As Range
Set oRange = ActiveDocument.Tables(2).Range
With oRange
'collapse oRange to a point at the end of Table 2:
.Collapse wdCollapseEnd
'insert next-page-section-break right after Table 2:
.InsertBreak wdSectionBreakNextPage
'insert a paragraph right after the section break:
.InsertParagraphAfter
'
'If I understand correctly, the insertion point
'at this point should still be where oRange was
'collapsed--at the end of Table 2.
End With
oRange.Select
With Selection
.TypeText "TOC"
End With
'
' But here, "TOC" appears right after
' the inserted paragraph, not right
' after Table 2. Isn't oRange now still
' just a point after Table 2?
Any feedback greatly appreciated.
Thanks so much!
-Lynne