FP2000: How to Configure FrontPage to Save Pages Before Publishing

ID: Q243091


The information in this article applies to:
  • Microsoft FrontPage 2000


SUMMARY

The sample code in this article demonstrates how to configure FrontPage 2000 to prompt to save unsaved pages before a Web is published.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

For more information about using the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
Q212536 OFF2000: How to Run Sample Code from Knowledge Base Articles
To configure FrontPage 2000 to prompt to save unsaved pages before a Web is published, use the following steps.
  1. Open FrontPage and press ALT+F11 to open the Visual Basic Editor.


  2. To create a new class module, click Insert and select Class Module.


  3. In the Properties Window, change the name of the class module to myClassModule.


  4. Insert the following code into the new class module:


  5. 
    'Set up our event handler
    Dim WithEvents fpapp As FrontPage.Application
    
    Private Sub Class_Initialize()
    
        'Set up the fpapp object
        Set fpapp = Application
        
    End Sub
    
    Private Sub fpapp_OnBeforeWebPublish(ByVal pWeb As Web, _
      Destination As String, Cancel As Boolean)
        
        'Set up variables
        Dim myPageWindow As PageWindow
        Dim myPageWindows As PageWindows
        
        'Set myPageWindows to equal the PageWindows collection
        Set myPageWindows = ActiveWebWindow.PageWindows
    
        'Loop through all of the open pages
        For Each myPageWindow In myPageWindows
            
            'If changes have been made to the page since last saved
            If myPageWindow.IsDirty Then
                
                'Create a variable for the result of message box
                Dim myResponse As VbMsgBoxResult
    
                'Activate the current page
                myPageWindow.Activate
                
                'Display a message asking if you'd like to save changes
                'to the page
                myResponse = MsgBox _
                  ("Would you like to save changes to this page?", _
                    vbYesNoCancel + vbExclamation)
                    
                'Take action based upon which button is clicked 
                'in the message box
                Select Case myResponse
                
                    Case vbYes  'Save Changes to Page
                        
                        'Execute the Save command on the file menu
                        CommandBars("File").Controls("&Save").Execute
                        
                    Case vbNo
                    
                        'Do nothing
                        
                    Case vbCancel   'Cancel publishing
                    
                        'By setting Cancel to true, publishing is stopped
                        Cancel = True
                        
                End Select
                
            End If
            
        Next myPageWindow
        
    End Sub 
  6. Create a new module by clicking Module on the Insert menu. This module can be named anything you like.


  7. Insert the following code into the new module:


  8. 
       'Set up memory for object from our Class Module
       'myClassModule is what we named our Class Module
       Public fpapp As myClassModule
    
       Sub PrepPublish()
    
           'Create new myClassModule object
           Set fpapp = New myClassModule
        
       End Sub
      
  9. Run the PrepPublish macro.


After you run the PrepPublish macro, if you attempt to publish a Web and you have unsaved pages open, you are prompted to save the unsaved pages.

You must run the PrepPublish macro each time FrontPage is started if you always want to be prompted to save pages before publishing. You can create a COM add-in from this code to enable this functionality without having to run the macro.

For additional information about creating a COM add-in, click the article number below to view the article in the Microsoft Knowledge Base:
Q232680 FP2000: How to Work with COM Add-ins in FrontPage 2000

Additional query words:

Keywords :
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: December 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.