Document Property Example

This example opens a page and uses the insertAdjacentText method to add text to the document.

Note   To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). In either case, you may substitute an alternative web URL or file. You must also have a file named Sales.htm or substitute an alternative file.

Private Sub AddTextToDoc()
Dim myWeb As Web
Dim myPageWindow As PageWindow
Dim myText As String

Set myWeb = _
    Webs.Open("C:\My Documents\My Webs\Rogue Cellars")
myWeb.Activate
myText = "Winter Sale Begins November 1st!"
Set myPageWindow = _
    ActiveWeb.RootFolder.Files("Sales.htm").Edit

myPageWindow.Document.body.insertAdjacentText _
    "BeforeEnd", myText

ActivePageWindow.Save
ActiveWeb.Close
End Sub