Share via


Understanding the Application Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Application object is the top-level object in the Microsoft® FrontPage® object model. It represents FrontPage itself and provides access to all of the objects in the FrontPage object model. If you are automating FrontPage from another Microsoft® Office application, you should set a reference to the Microsoft FrontPage Page Object Reference library by clicking References on the Tools menu in the Microsoft® Visual Basic® Editor in the application from which you are working. Then, you can write code to create an instance of an Application object variable, as shown in the following example:

Dim fpApp As FrontPage.Application

Set fpApp = New FrontPage.Application

To create a FrontPage Application object without setting a reference to the FrontPage 4.0 Object Reference library, you can use the CreateObject function.

If you are writing Microsoft® Visual Basic® for Applications (VBA) code from within the FrontPage VBA project, you can refer to the Application object directly without creating an object variable.

From the Application object, you can reach any other object in the FrontPage object model. In addition, the properties, methods, and events of the Application object are also global properties that you can use to return currently active objects. A global property is a property that you can use to return an object without having to refer to the Application object or any top-level objects. The global properties that represent active objects in FrontPage are ActiveDocument, ActivePageWindow, ActiveWeb, and ActiveWebWindow. The following examples illustrate how you can work with these properties and the objects they represent:

' Apply the classic theme to the active document and specify
' vivid colors and active graphics.
ActiveDocument.ApplyTheme "classic", fpThemeVividColors + fpThemeActiveGraphics

' Locate the HelpInformation.htm file in the currently active web.
Dim wflCurrentFile As WebFile

Set wflCurrentFile = ActiveWeb.LocateFile("HelpInformation.htm")
If Not wflCurrentFile Is Nothing Then
   With wflCurrentFile
      ' Code to work with found file here.
   End With
End If

' Check to see if the page in the active page window has changed and, 
' if so, save it to disk.
With ActivePageWindow
   If .IsDirty Then
      .Refresh SaveChanges:=True
   End If
End With

' Display a message showing the window captions for all open 
' documents in the active web window.
Dim pgeCurr          As PageWindow
Dim strCaptions      As String

If ActiveWebWindow.PageWindows.Count > 0 Then
   For Each pgeCurr In ActiveWebWindow.PageWindows
      strCaptions = strCaptions & pgeCurr.Caption & vbCrLf
   Next pgeCurr
   If Len(strCaptions) > 0 Then
      MsgBox "The following pages are currently open:" & vbCrLf & strCaptions
   End If
End If

The Application object also exposes properties you can use to get information about the current machine, such as the user's name, the version of FrontPage, the language settings, the registry values, and so on. You can use the System property to return the System object, which provides information about the operating system and screen resolution. You also can use the ProfileString property of the System object to read and write FrontPage registry values.

In addition to getting information about the current machine, the Application object provides 10 application-level events you can use to run VBA code when the events occur.

See Also

Working with Microsoft FrontPage Objects | Understanding the FrontPage Object Model