HTMLDivision Object

Microsoft Word Visual Basic

HTMLDivision Object

HTMLDivisions HTMLDivision
Multiple objects

Represents a single HTML division that can be added to a Web document. The HTMLDivision object is a member of the HTMLDivisions collection.

Using the HTMLDivision object

Use HTMLDivisions (index), where index refers to the HTML division in the document, to return a single HTMLDivision object. Use the Borders property to format border properties for an HTML division. This example formats three nested divisions in the active document. This example assumes that the active document is an HTML document with at least three divisions.

Sub FormatHTMLDivisions()
    With ActiveDocument.HTMLDivisions(1)
        With .Borders(wdBorderLeft)
            .Color = wdColorRed
            .LineStyle = wdLineStyleSingle
        End With
        With .Borders(wdBorderTop)
            .Color = wdColorRed
            .LineStyle = wdLineStyleSingle
        End With
        With .HTMLDivisions(1)
            .LeftIndent = InchesToPoints(1)
            .RightIndent = InchesToPoints(1)
            With .Borders(wdBorderRight)
                .Color = wdColorBlue
                .LineStyle = wdLineStyleDouble
            End With
            End With
            With .Borders(wdBorderBottom)
                .Color = wdColorBlue
                .LineStyle = wdLineStyleDouble
            End With
            With .HTMLDivisions(1)
                .LeftIndent = InchesToPoints(1)
                .RightIndent = InchesToPoints(1)
                With .Borders(wdBorderLeft)
                    .Color = wdColorBlack
                    .LineStyle = wdLineStyleDot
                End With
                With .Borders(wdBorderTop)
                    .Color = wdColorBlack
                    .LineStyle = wdLineStyleDot
                End With
            End With
        End With
    End With

End Sub
		

HTML divisions can be nested within multiple HTML divisions. Use the HTMLDivisionParent method to access a parent HTML division of the current HTML division. This example formats the borders for two HTML divisions in the active document. This example assumes that the active document is an HTML document with at least two divisions.

Sub FormatHTMLDivisions()
    With ActiveDocument.HTMLDivisions(1)
        With .HTMLDivisions(1)
            .LeftIndent = InchesToPoints(1)
            .RightIndent = InchesToPoints(1)
            With .Borders(wdBorderLeft)
                .Color = wdColorBlue
                .LineStyle = wdLineStyleDouble
            End With
            With .Borders(wdBorderRight)
                .Color = wdColorBlue
                .LineStyle = wdLineStyleDouble
            End With
            With .HTMLDivisionParent
                .LeftIndent = InchesToPoints(1)
                .RightIndent = InchesToPoints(1)
                With .Borders(wdBorderTop)
                    .Color = wdColorBlack
                    .LineStyle = wdLineStyleDot
                End With
                With .Borders(wdBorderBottom)
                    .Color = wdColorBlack
                    .LineStyle = wdLineStyleDot
                End With
            End With
        End With
    End With
End Sub