HTMLDivision 对象

         
HTMLDivisions
HTMLDivision
多种对象

该对象代表可添加至 Web 文档的单独的 HTML 区域。HTMLDivision 对象是 HTMLDivisions 集合的一个成员。

使用 HTMLDivision 对象

使用 HTMLDivisions(index) 可返回单独的 HTMLDivision 对象,其中 index 引用文档中的 HTML 区域。使用 Borders 属性可设置 HTML 区域边框格式的属性。本示例设置活动文档中三个嵌套区域的格式。本示例假定该活动文档是一个 HTML 文档,其中具有至少三个区域。

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 区域可在多个 HTML 区域中嵌套。使用 HTMLDivisionParent 方法可访问当前 HTML 区域的 HTML 父区域。本示例设置活动文档中两个 HTML 区域的边框格式,本示例假定该活动文档是一个 HTML 文档,其中具有至少两个区域。

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