William said:
hi,
i'm trying to create a section break with the type
wdSectionBreakContinuous after a table. how can i do that in vba for
word xp?
Hi William,
The general idea is to assign a Range object to the range of the table and
then collapse the range to its end. The range is then between the end of the
table and the next character, and that's where you can insert the section
break.
A small twist is that a table at the end of a document always has an empty
paragraph mark after it, and you don't really want to add a section break
there. The macro below takes this into account.
If you don't want a break after every table, you'll have to assign oTbl to a
particular table -- for example, ActiveDocument.Tables(3) -- and remove the
For Each...Next loop.
Sub SectionAfterTable()
Dim oTbl As Table
Dim oRg As Range
For Each oTbl In ActiveDocument.Tables
Set oRg = oTbl.Range
oRg.Collapse wdCollapseEnd
If oRg.End < ActiveDocument.Range.End - 1 Then
oRg.InsertBreak _
Type:=wdSectionBreakContinuous
End If
Next oTbl
End Sub