HTMLDivisions Collection

Microsoft Word Visual Basic

HTMLDivisions Collection

         
Multiple objects HTMLDivisions
HTMLDivision

A collection of HTMLDivision objects that represents the HTML divisions that exist in a Web document.

Using the HTMLDivisions collection

Use the HTMLDivisions property to return the HTMLDivisions collection. Use the Add method to add an HTML division to a Web document. This example adds a new HTML division to the active document, adds text to the division, and formats the borders around the division.

Sub NewDivision()

    With ActiveDocument.HTMLDivisions
        .Add
        .Item(Index:=1).Range.Text = "This is a new HTML division."
        With .Item(1)
            With .Borders(wdBorderBottom)
                .LineStyle = wdLineStyleTriple
                .LineWidth = wdLineWidth025pt
                .Color = wdColorRed
            End With
            With .Borders(wdBorderTop)
                .LineStyle = wdLineStyleDot
                .LineWidth = wdLineWidth050pt
                .Color = wdColorBlue
            End With
            With .Borders(wdBorderLeft)
                .LineStyle = wdLineStyleDouble
                .LineWidth = wdLineWidth075pt
                .Color = wdColorBrightGreen
            End With
            With .Borders(wdBorderRight)
                .LineStyle = wdLineStyleDashDotDot
                .LineWidth = wdLineWidth075pt
                .Color = wdColorTurquoise
            End With
        End With
    End With

End Sub