Export (0) Print
Expand All

Web Object

Represents a Web site.

Remarks

The Web object is a member of the Webs collection, which represents all of the open Web sites in Office SharePoint Designer. Office SharePoint Designer provides the ability to create multiple Web objects on a Web server. Within the Webs collection, individual Web objects are indexed beginning with zero. The directory hierarchy of a Web site in Office SharePoint Designer is similar to a folder hierarchy. Any WebFolder can represent a Web site, but every WebFolder does not necessarily represent a Web site. The Web folder hierarchy provides the link to folders and files on a Web server directory.

Use the Web property to return the Web object. The following example checks the operating system of the Web site for the capability of processing long file names.

  Note
To run this example, create a form with a command button named cmdCheckLongFilenames and a text box named txtLongFilenames, and copy the example into the code window.
Visual Basic for Applications
Private Sub cmdCheckLongFilenames()

    Dim objPageWin As PageWindow
    Set objPageWin = ActivePageWindow

    With objPageWin
        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 ordinal position of a Web site in the Webs collection, to return a single Web object. The following example returns the URL of the first Web site in the Webs collection.

Visual Basic for Applications
Application.Webs(0).Url

Use the ActiveWebWindow property to return the selected WebWindow object. From the WebWindow object, you can access the ActiveDocument, ActivePageWindow, or Application properties, 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 Microsoft Visual Basic for Applications (VBA), the WebWindow object returns the date in string format and does not automatically convert the string to a date format.
Visual Basic for Applications
Private Sub ActiveDocDateSize()
    Dim objWebWindow As WebWindow
    Dim strFileSize As String
    Dim strCreateDate As String

    Set objWebWindow = ActiveWebWindow

    With objWebWindow
        strFileSize =.ActiveDocument.fileSize
        strCreateDate =.ActiveDocument.fileCreatedDate
    End With
End Sub

The RevisionControlProject and IsUnderRevisionControl properties return the status of the revision state of the Web object. You can control versioning in Office SharePoint Designer through Microsoft Visual SourceSafe or through Microsoft Office–style locking. For more information on source control projects and Office-style locking, see Managing Source Control.

If a revision control project does not correspond to a valid Visual SourceSafe project, Office SharePoint Designer 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 site open.
Visual Basic for Applications
Private Sub SourceControl()
    Dim objWeb As Web

    Set objWeb = ActiveWeb
    If Not(objWeb.IsUnderRevisionControl) Then
        objWeb.RevisionControlProject = "<FrontPage-based Locking>"
    End If
End Sub

Private Sub ReturnRevisionState()
    Dim objWeb As Web
    Dim strRevCtrlProj As String
    Dim blnIsUnderRevCtrl As Boolean

    Set objWeb = ActiveWeb

    With objWeb
        RevCtrlProj =.RevisionControlProject
        blnIsUnderRevCtrl =.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 site. The RootNavigationNode object is created by default when you create a Web site 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 site. The following example returns the name of the root folder and the URL of the RootNavigationNode object.

Visual Basic for Applications
Private Sub GetRootInfo()
    Dim objWeb As Web
    Dim strRootFolder As String
    Dim strHomeNavNode As String

    Set objWeb = ActiveWeb

    With objWeb
        strRootFolder =.RootFolder.Name
        strHomeNavNode =.RootNavigationNode.Children(0).Url
    End With
End Sub

Use the SharedBorders property to set the shared borders for a Web site either on or off. The following statement sets the SharedBorders property to True and turns shared borders on for the specified Web site.

Visual Basic for Applications
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.

Visual Basic for Applications
Application.WebWindows.Count

Using the Web object methods

Use the Activate method to place the focus on the current object. The following statements determine whether myAdventureWorksWeb is the active Web site; if not, myAdventureWorksWeb is activated.

Visual Basic for Applications
If ActiveWeb <> myAdventureWorksWeb Then
    objAdventureWorksWeb.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 site, where the variable for the Adventure Works Web site is webAdventureWorksWeb.

Visual Basic for Applications
myAdventureWorksWeb.ApplyNavigationStructure

Use the CancelRequests method to cancel all server requests. The following statement cancels all server requests for the Adventure Works Web site, with webAdventureWorksWeb as the Web object 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.
Visual Basic for Applications
myAdventureWorksWeb.CancelRequests

Use the LocateFile or LocateFolder methods to return a WebFile or a WebFolder object within a Web site. The following example locates a folder for a disk-based Web site.

Visual Basic for Applications
Application.Web.LocateFolder("C:\My Web Sites\Adventure Works\images")

Use the Publish method to publish a Web site to a Web server. The following statement publishes the Adventure Works Web site to a Personal Web Server site.

Visual Basic for Applications
Dim objWeb As Web

Set objWeb = Application.Web

With objWeb
.Publish _
    "http://myServer/wwwroot", fpPublishAddToExistingWeb

The WebPublishFlags enumerated types can be concatenated as shown in the following statement.

Visual Basic for Applications
myWeb.Publish _
    "http://myServer/wwwroot", fpPublishAddToExistingWeb + _
    fpPublishCopySubwebs



Community Additions

ADD
Show:
© 2014 Microsoft