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.
Because the Web already exists, you should use the fpPublishAddToExistingWeb publish flag when publishing to a Web.
NOTE: When you use Microsoft FrontPage 2002, Microsoft recommends you use the fpPublishNoDeleteUnmatched flag so that content that is in conflict will not be deleted.
The following sample Visual Basic code prompts for a source and destination Web and adds the appropriate publish flags when it publishes the source Web to the destination Web.
Sub PublishWeb()
' Set up variables. For FrontPage 2000 compatibility, dim the source
' and destination Webs as "As Web". For FrontPage 2002 compatibility,
' dim these variables as "As WebEx".
Dim sSourceWebURL As String
Dim sDestWebURL As String
Dim oSourceWeb As Web
Dim oDestWeb As Web
' Prevent any errors from crashing.
On Error Resume Next
' Prompt for the source Web.
sSourceWebURL = InputBox("Enter source URL:" & vbCrLf & _
"If this is a server-based Web, include 'http://' in the URL.", _
"Publish Web")
' Prompt for the destination Web.
sDestWebURL = InputBox("Enter destination URL:" & _
"If this is a server-based Web, include 'http://' in the URL.", _
"Publish Web")
' Check to make sure you have both URLs.
If sSourceWebURL = "" Or sDestWebURL = "" Then
MsgBox "You must enter a source and destination URL." _
& "Please try again."
Exit Sub
End If
' Open the source Web.
Set oSourceWeb = Webs.Open(sSourceWebURL)
' See if the source Web exists.
If oSourceWeb Is Nothing Then
MsgBox "The source Web could not be found." _
& "Please try again."
Exit Sub
End If
' The Add method creates the Web if it doesn't exist. Therefore,
' by using this method, you will always publish with the
' fpPublishAddToExistingWeb flag.
Set oDestWeb = Webs.Add(sDestWebURL)
If oDestWeb Is Nothing Then
MsgBox "The destination Web could not be created." _
& "Please try again."
ActiveWebWindow.Close
oSourceWeb.Close
Exit Sub
End If
' Close the ActiveWebWindow. The ActiveWebWindow contains the
' destination Web at this point, and since it's already done its job,
' you no longer need to keep it open.
ActiveWebWindow.Close
'Publish the Web
oSourceWeb.Publish sDestWebURL, fpPublishAddToExistingWeb
End Sub