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.

The main procedures of class HTMLDivision are Delete and HTMLDivisions.Add


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)

The following procedures can be used to set variables of type HTMLDivision: HTMLDivisionParent, HTMLDivisions.Add, HTMLDivisions.Item, Document.HTMLDivisions, HTMLDivisions, Range.HTMLDivisions and Selection.HTMLDivisions

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


These are the main methods of the HTMLDivision class

Delete - Deletes the specified HTML division.


HTMLDivisions.Add - Returns an HTMLDivision object that represents a new HTML division added to a web document.

Dim htm As HTMLDivision
Set htm = ActiveDocument.Range.HTMLDivisions.Add()


Borders returns a Borders collection that represents all the borders for the specified object.

Dim brdsBorders As Borders
Set brdsBorders = ActiveDocument.Range.HTMLDivisions(1).Borders

HTMLDivisions returns an HTMLDivisions object that represents an HTML division in a web document.

Dim htmsHTMLDivisions As HTMLDivisions
Set htmsHTMLDivisions = ActiveDocument.Range.HTMLDivisions(1).HTMLDivisions

LeftIndent returns or sets a Single that represents the left indent value (in points) for the specified HTML division.

ActiveDocument.Range.HTMLDivisions(1).LeftIndent =

Parent returns an object that represents the parent object of the specified HTMLDivision object.

Dim objParent As Object
Set objParent = ActiveDocument.Range.HTMLDivisions(1).Parent

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.Range.HTMLDivisions(1).RightIndent =

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 =

HTMLDivisions.Count returns a Long that represents the number of HTML DIV elements in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.Range.HTMLDivisions.Count

HTMLDivisions.NestingLevel returns the nesting level of the specified HTML DIV elements.

Dim lngNestingLevel As Long
lngNestingLevel = ActiveDocument.Range.HTMLDivisions.NestingLevel

HTMLDivisions.Parent returns an object that represents the parent object of the specified HTMLDivisions object.

Dim objParent As Object
Set objParent = ActiveDocument.Range.HTMLDivisions.Parent