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.
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
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:
'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
|
5. | Create a new module by clicking Module on the Insert menu. This module can be named anything you like. |
6. | Insert the following code into the new module:
'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
|
7. | 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:
232680 FP2000: How to Work with COM Add-ins in FrontPage 2000