insertAdjacentText Method

Microsoft FrontPage Visual Basic

expression.insertAdjacentText(where, text)

expression    Required. An expression that returns one of the objects in the Applies To list.

where    Required String. String that specifies where to insert the text. Can be one of the following values :

beforeBegin Inserts the specified text immediately before the opening element of the object.
afterBegin Inserts the specified text immediately after the opening element of the object but before all other content in the object.
beforeEnd Inserts the specified text immediately before the end of the object but after all other content in the object.
afterEnd Inserts the specified text immediately after the end of the object.

The following image illustrates where text or HTML is inserted when you use each of the above String values.

Where text or HTML is inserted.

text    Required String. String that specifies the text to insert.

Remarks

Use the insertAdjacentHTML method to insert text that contains HTML. In addition, you can use the outerHTML and outerText properties to insert HTML and text outside the specified element, and the innerHTML and innerText properties to insert HTML and text inside the specified element. The following image illustrates where each of these properties applies. Note that the innerHTML and outerHTML properties require well-formed HTML.

NONE

Example

The following example inserts the date when the specified document was last modified into the specified document and formats it with the specified font name, font size, and color.

Sub AddModifiedDateToDocument(objDoc As FPHTMLDocument, strFont As String, _
        strSize As String, strColor As String)
    
    Dim objFont As FPHTMLFontElement
    
    objDoc.body.insertAdjacentHTML where:="beforeEnd", _
        HTML:="<p><font id=""filename""></font></p>"
    
    Set objFont = objDoc.body.all.tags("font").Item("filename")
    objFont.insertAdjacentText "beforeEnd", "Last modified on: " _
        & objDoc.fileModifiedDate
    
    With objFont
        .face = strFont
        .Size = strSize
        .Color = strColor
    End With
End Sub
		

Use the following example to call the preceding example.

Sub CallAddModifiedDateToDocument()
    Call AddModifiedDateToDocument(ActiveDocument, "Arial", "2", "Blue")
End Sub