My HTML typically contains about 5 div elements contained inside one div element.

This function will get the index number of the div element that I want to work with.

Function GetElementIndex( _
ByVal strAttribute As String, _
ByVal strAttributeValue As String) _
As Integer
   On Error GoTo errHandler1
   For j = 0 To _
   ActiveDocument.all.tags(strAttribute).Length - 1
      If ActiveDocument.all.tags(strAttribute). _
      Item(j).ID = strAttributeValue Then
         GetElementIndex = j
         Exit Function
      End If
   Next j
   GetElementIndex = -1
   Exit Function
errHandler1:
   MsgBox "GetElementIndex has failed", _
   vbCritical, "Function failure."
   Exit Function

End Function

Calling Procedure for this Function.

All of my div elements have unique id values such as
 <div id="navheader">.

strID has to be set to "navheader" and then the procedure will look through all of the elements with a tagname of "div" until it finds the one that has id="navheader".

 

Valid XHTML 1.0 Transitional        Valid CSS!