HTMLDivisions 集合

         
多种对象
HTMLDivisions
HTMLDivision

该集合由 HTMLDivision 对象组成,这些对象代表 Web 文档中存在的 HTML 区域。

使用 HTMLDivisions 集合

使用 HTMLDivisions 属性可返回 HTMLDivisions 集合。使用 Add 方法可在 Web 文档中添加 HTML 区域。本示例将一个新的 HTML 区域添至活动文档,在该区域中添加文字,并设置区域周围边框的格式。

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