CreateNew Method

Microsoft Office Visual Basic

CreateNew Method

Creates a new document workspace on the server and adds the active document to the new shared workspace.

expression.CreateNew(URL, Name)

expression    Required. An expression that returns a SharedWorkspace object.

URL    Optional String. The URL for the parent folder in which the new shared workspace is to be created. If you do not supply a URL, the new shared workspace is created in the user's default server location.

Name    Optional String. The name of the new shared workspace. Defaults to the name of the active document without its file extension. For example, if you create a shared workspace for "Budget.xls", the name of the new shared workspace becomes "Budget".

Remarks

Use the CreateNew method to create a new shared workspace for the active document. Omit the 2 optional arguments to create the workspace using the name of the active document in the user's default server location.

The CreateNew method raises an error if the active document has changes that have not been saved. The document must be saved before it can be added to a shared workspace.

Example

The following example creates a new shared workspace at the URL http://server/sites/mysite/, names the workspace "My Shared Budget Document", and adds the active document to the workspace. The URL property of the new shared workspace returns http://server/sites/mysite/My%20Shared%20Budget%20Document/, the Name property returns "My Shared Budget Document, and Count property of the Files collection shows a single file.

        Dim sws As Office.SharedWorkspace
    Dim strSWSInfo As String
    Set sws = ActiveWorkbook.SharedWorkspace
    sws.CreateNew "http://server/sites/mysite/", "My Shared Budget Document"
    strSWSInfo = "Name: " & sws.Name & vbCrLf & _
        "URL: " & sws.URL & vbCrLf & _
        "File(s): " & sws.Files.Count
    MsgBox strSWSInfo, vbInformation + vbOKOnly, _
        "New Shared Workspace Information"
    Set sws = Nothing