Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FP2000: How to Invoke a New FrontPage Window Using Visual Basic for Applications


View products that this article applies to.

This article was previously published under Q240904

↑ Back to the top


Summary

This article explains how to create the appearance of a new instance of FrontPage using Visual Basic for Applications.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The FrontPage Application object is a single-instance object. Therefore, if you attempt to programmatically create a new instance of FrontPage 2000 when an instance is already running, a new instance is not created.

Using the code below, you can create a new FrontPage window to create the appearance of a new instance of FrontPage.

To use this macro, create a new user form and place a Command Button control on it. Name the Command Button "myButton" and add the following code to the form:
'**********************************************************************
'What we do is attempt to get a 
'reference to an instance of FrontPage.  If FrontPage is not running, 
'this will generate an error and take us to our error handling routine.
'The error handling routine checks to make sure that the error number
'is what we would expect if an instance of FrontPage is not running.
'We then create a new instance of FrontPage.
'**********************************************************************
Private Sub myButton_Click()
    'Set up variables 
    Dim myFPApp As FrontPage.Application
    
    'Error handler in case FrontPage is not already running
    On Error GoTo ErrorHandler

    'Get a reference to a running FrontPage Application object
    Set myFPApp = GetObject(, "FrontPage.Application")

    'Execute the New Window command on the Window menu
    myFPApp.CommandBars.FindControl(Id:=303).Execute
    

    'Exit the sub procedure
    Exit Sub

ErrorHandler:

    'Check for the Error Number
    If Err.Number = 429 Then

        'Error 429 is a "Can't Create Object" error
        'This means that an instance of FrontPage is not running
        'Therefore, create an instance of FrontPage
        Set myFPApp = CreateObject("FrontPage.Application")

        'Make our new instance visible
        myFPApp.WebWindows(0).Visible = True

    End If 
End Sub
				

This code is intended to be run outside of FrontPage to create a new FrontPage application window using automation. This can be done with this code from another Office 2000 application or using Microsoft Visual Basic for Applications to automate FrontPage 2000.

↑ Back to the top


References

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

↑ Back to the top


Keywords: KB240904, kbhowto

↑ Back to the top

Article Info
Article ID : 240904
Revision : 2
Created on : 6/18/2005
Published on : 6/18/2005
Exists online : False
Views : 287