Class HTMLDivision (Word VBA)
The class HTMLDivision represents a single HTML DIV element within a web document. The HTMLDivision object is a member of the HTMLDivisions collection. To use a HTMLDivision class variable it first needs to be instantiated, for example
Dim htm as HTMLDivision
Set htm = ActiveDocument.Range.HTMLDivisions(Index:=1)
For Each
Here is an example of processing the HTMLDivision items in a collection.
Dim htm As HTMLDivision
For Each htm In ActiveDocument.Range.HTMLDivisions
Next htm
Borders
Returns a Borders collection that represents all the borders for the specified object.
For information about returning a single member of a collection, see Returning an object from a collection.
Dim brdsBorders As Borders
Set brdsBorders = ActiveDocument.Range.HTMLDivisions(1).Borders
Delete
Deletes the specified HTML division.
ActiveDocument.Range.HTMLDivisions(1).Delete
HTMLDivisionParent
Returns an HTMLDivision object that represents a parent division of the current HTML division.
HTMLDivisionParent (LevelsUp)
LevelsUp: The number of parent divisions to count back to return the desired division. If the LevelsUp argument is omitted, the HTML division returned is one level up from the current HTML division.
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
HTMLDivisions
Returns an HTMLDivisions object that represents an HTML division in a web document.
Sub FormatHTMLDivisions()
With ActiveDocument.HTMLDivisions(1)
With .Borders(wdBorderLeft)
.Color = wdColorRed
.LineStyle = wdLineStyleSingle
End With
With .Borders(wdBorderRight)
.Color = wdColorRed
.LineStyle = wdLineStyleSingle
End With
With .HTMLDivisions(1)
.LeftIndent = InchesToPoints(1)
.RightIndent = InchesToPoints(1)
With .Borders(wdBorderTop)
.Color = wdColorBlue
.LineStyle = wdLineStyleDouble
End With
With .Borders(wdBorderBottom)
.Color = wdColorBlue
.LineStyle = wdLineStyleDouble
End With
With .HTMLDivisions(1)
.LeftIndent = InchesToPoints(1)
.RightIndent = InchesToPoints(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleDot
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleDot
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleDot
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleDot
End With
End With
End With
End With
End Sub
LeftIndent
Returns or sets a Single that represents the left indent value (in points) for the specified HTML division.
ActiveDocument.Range.HTMLDivisions(1).LeftIndent =
Range
Returns a Range object that represents the portion of a document that's contained in the specified object.
Dim rngRange As Range
Set rngRange = ActiveDocument.Range.HTMLDivisions(1).Range
RightIndent
Returns or sets the right indent (in points) for the specified paragraphs.
ActiveDocument.Paragraphs.RightIndent = InchesToPoints(1)
SpaceAfter
Returns or sets the amount of spacing (in points) after the specified HTML DIV element.
ActiveDocument.Range.HTMLDivisions(1).SpaceAfter =
SpaceBefore
Returns or sets the spacing (in points) before the specified HTML DIV element.
ActiveDocument.Range.HTMLDivisions(1).SpaceBefore =