Using the Web Object Properties
Use the Web property to return the Web object. The following example checks the web’s operating system for the capability of processing long file names.
Note To run this example, create a form with a command button called cmdCheckLongFilenames
, a text box called txtLongFilenames
, and copy the example into the code window.
Private Sub cmdCheckLongFilenames()
Dim myPageWin As PageWindow
Set myPageWin = ActivePageWindow
With myPageWin
If .Web.AllowsLongFilenames = True Then
txtLongFilenames = _
“This operating system uses long file names.”
Exit Sub
Else
txtLongFilenames = _
“This operating system only uses short file names.”
End If
End With
End Sub
Use Webs(index), where index is the index number of a web item, to return a single Web object. The following example returns the URL of the first web item in the Webs collection.
Application.Webs(0).Url
Use the ActiveWebWindow property to return the selected ActiveWebWindow object. From the ActiveWebWindow object, you can access the ActiveDocument, ActivePageWindow, or Application objects, along with properties such as Caption, PageWindows, Parent, ViewMode, Visible, and Web. The following example returns the creation date and file size of the active document.
Note Although Date is an available type in Visual Basic for Applications, the ActiveDocument object returns the date in string format and does not automatically convert the string to a date format.
Private Sub ActiveDocDateSize()
Dim myWebWindow As WebWindow
Dim myFileSize As String
Dim myCreateDate As String
Set myWebWindow = ActiveWebWindow
With myWebWindow
myFileSize = .ActiveDocument.fileSize
myCreateDate = .ActiveDocument.fileCreatedDate
End With
End Sub
The RevisionControlProject and IsUnderRevisionControl properties return the status of the Web object’s revision state. You can control versioning in Microsoft FrontPage through Microsoft Visual SourceSafe or through Microsoft Office style locking. For more information on source control projects and Office style locking, refer to Managing Source Control.
If a revision control project does not correspond to a valid Visual SourceSafe project, FrontPage defaults to Office style locking. The following example returns the RevisionControlProject and IsUnderRevisionControl properties, and includes a source control project example.
Note To run this example, create a module and copy the example into the code window. You must have a web open.
Private Sub SourceControl()
Dim myWeb As Web
Set myWeb = ActiveWeb
If Not(myWeb.IsUnderRevisionControl) Then
MyWeb.RevisionControlProject = "<FrontPage-based Locking>"
End If
End Sub
Private Sub ReturnRevisionState()
Dim myWeb As Web
Dim myRevCtrlProj As String
Dim myIsUnderRevCtrl As Boolean
Set myWeb = ActiveWeb
With myWeb
myRevCtrlProj = .RevisionControlProject
myIsUnderRevCtrl = .IsUnderRevisionControl
End With
End Sub
Use the RootFolder and RootNavigationNode properties to determine the root folder or root navigation node. The RootFolder property returns a pointer to the root folder of a Web site. The RootNavigationNode property returns the NavigationNode object from which you can access all other navigation nodes in a web. The RootNavigationNode object is created by default when you create a Web, and provides the basis for the navigation structure, which is accessed through the Children property. The first child node of the navigation structure is the home page of the web. The following example returns the name of the root folder and the URL of the RootNavigationNode object.
Private Sub GetRootInfo()
Dim myWeb As Web
Dim myRootFolder As String
Dim myHomeNavNode As String
Set myWeb = ActiveWeb
With myWeb
myRootFolder = .RootFolder.Name
myHomeNavNode = .RootNavigationNode.Children(0).Url
End With
End Sub
Use the SharedBorders property to set the shared borders for a web either on or off. The following statement sets the SharedBorders property to True and turns shared borders on for the specified web.
ActiveWeb.SharedBorders(fpBorderTop) = True
Use the WebWindows property to return the collection of WebWindow objects that are contained within the current Web object. The following statement returns a count of the WebWindows collection.
Application.WebWindows.Count
Using the Web Object Methods
Use the Activate method to place the focus on the current object. The following statements check if myAdventureWorksWeb
is the active web; if it is not, then myAdventureWorksWeb
is activated.
If ActiveWeb <> myAdventureWorksWeb Then
myAdventureWorksWeb.Activate
End If
Use the ApplyNavigationStructure method to apply a newly created or modified navigation structure to a Web site. The following statement applies a navigation structure to a web, where the variable for the Adventure Works web is webAdventureWorks
.
myAdventureWorksWeb.ApplyNavigationStructure
Use the CancelRequests method to cancel all server requests. The following statement cancels all server requests for the Adventure Works web, with webAdventureWorks
as the web variable.
Note The client will stop all requests to the server; however, the server may have already started a transaction, in which case it will continue until the transaction is finished and then the remaining requests (if any) will be cancelled.
myAdventureWorksWeb.CancelRequests
Use the LocateFile or LocateFolder methods to return a WebFile or a WebFolder object within a web. The following example locates a folder for a disk-based web.
Application.Web.LocateFolder("C:\My Webs\Adventure Works\images")
Use the Publish method to publish a web to a Web server. The following statement publishes the Adventure Works web to a Personal Web Server site.
Dim myWeb As Web
Set myWeb = Application.Web
With myWeb
.Publish _
"http://myServer/wwwroot", fpPublishAddToExistingWeb
The FpWebPublishFlags enumerated types can be concatenated as shown in the following statement.
myWeb.Publish _
"http://myServer/wwwroot", fpPublishAddToExistingWeb + _
fpPublishCopySubwebs
Use the RecalcHyperlinks method to update the display all of the hyperlinks in a web. You may want to recalculate hyperlinks often when you have a multiuser environment with many people making changes to the web. When you recalculate hyperlinks, FrontPage also performs other processes such as deleting unused themes and updating component information on the server. The following statement recalculates the hyperlinks in the Adventure Works web.
webAdventureWorks.RecalcHyperlinks
Use the Refresh method to refresh a page. The following statements refresh a page and the active web.
myPage.Refresh
myWeb.Refresh