activeElement Property
Returns an object that represents the currently selected text or the location of the insertion point in the document.
expression.activeElement
expression Required. An expression that returns one of the objects in the Applies To list.
Remarks
The type of object returned depends on the location of the insertion point or the text selected in Microsoft FrontPage. For example, if you have a form button selected, the activeElement property returns an IHTMLInputButtonElement object; if you have a portion of text selected within a paragraph tag, it returns an IHTMLParaElement object; if you have several paragraphs selected, it returns an FPHTMLBody object. If you are unsure of the object that will be returned, you can use the IHTMLElement object to capture and manipulate the returned object, as shown in the example.
Example
The following example sets the className property for the active element if the active element is of the specified tag.
Sub SetClassForActiveElement(strTag As String, strClass As String)
Dim objElement As IHTMLElement
Dim strElement As String
Set objElement = ActiveDocument.activeElement
With objElement
If LCase(.tagName) = LCase(strTag) Then
If .className = "" Then
.className = strClass
End If
End If
End With
End Sub
Use the following subroutine to call the previous subroutine. This example assumes that you have a style called "blue" in the specified document or in a cascading style sheet reference in the specified document.
Sub CallSetClass()
Call SetClassForActiveElement("p", "blue")
End Sub