URL Property
As it applies to the SharedWorkspace object.
Returns the top-level Uniform Resource Locator (URL) of the shared workspace. Read-only String.
expression.URL
expression Required. An expression that returns a SharedWorkspace object.
Remarks
The URL property returns the address of the shared workspace in this format: http://server/sites/user/workspace/
.
The URL property returns a URL-encoded string. For example, a space in the folder name is represented by %20
. Use a simple function like the following example to replace this escaped character with a space.
Private Function URLDecode(URLtoDecode As String) As String
URLDecode = Replace(URLtoDecode, "%20", " ")
End Function
As it applies to the SharedWorkspaceFile object.
Returns the full Uniform Resource Locator (URL) and file name of the shared workspace file. Read-only String.
expression.URL
expression Required. An expression that returns a SharedWorkspaceFile object.
Remarks
The URL property returns the address of the shared workspace file in this format: http://server/sites/user/workspace/Shared%Documents/MyWorkbook.xls
.
The URL property returns a URL-encoded string. For example, a space in the folder name is represented by %20
.
The SharedWorkspaceFile object does not have a Name or FileName property. The filename must be extracted from the URL property. Use simple functions as in the following example to extract the filename and to decode spaces in the URL.
Private Function FilenameFromURL(FileURL As String) As String
Dim intLastSeparator As Integer
FileURL = URLDecode(FileURL)
intLastSeparator = InStrRev(FileURL, "/")
FilenameFromURL = Right(FileURL, Len(FileURL) - intLastSeparator)
End Function
Private Function URLDecode(URLtoDecode As String) As String
URLDecode = Replace(URLtoDecode, "%20", " ")
End Function
As it applies to the SharedWorkspaceLink object.
Returns or sets the Uniform Resource Locator (URL) of the link saved in the shared workspace. Read/write String.
expression.URL
expression Required. An expression that returns a SharedWorkspaceLink object.
Remarks
Use the URL property of the SharedWorkspaceLink object to retrieve the web address saved in the shared workspace link. Use the optional Description and Notes properties to retrieve additional information about the link.
The URL property returns a URL-encoded string. For example, a space in the folder name is represented by %20
. Use a simple function like the following example to replace this escaped character with a space.
Private Function URLDecode(URLtoDecode As String) As String
URLDecode = Replace(URLtoDecode, "%20", " ")
End Function
Example
As it applies to the SharedWorkspace object.The following example displays the base URL of the shared workspace.
MsgBox "URL: " & ActiveWorkbook.SharedWorkspace.URL, _
vbInformation + vbOKOnly, "Shared Workspace URL"
As it applies to the SharedWorkspaceFile object.
The following example locates all Microsoft Excel workbooks in the SharedWorkspaceFiles collection by examining the URL property of each file for the "xls" file extension.
Dim strExcelFiles As String
Dim swsFile As Office.SharedWorkspaceFile
For Each swsFile In ActiveWorkbook.SharedWorkspace.Files
If Right(swsFile.URL, 3) = "xls" Then
strExcelFiles = strExcelFiles & swsFile.URL & vbCrLf
End If
Next
MsgBox "Excel Files: " & vbCrLf & strExcelFiles, _
vbInformation + vbOKOnly, "Excel Files in Shared Workspace"
The following example lists all files in the shared workspace, using supporting functions to extract their filenames from the URL and to convert URL-encoded spaces from %20
to a space character.
Dim swsFile As Office.SharedWorkspaceFile
Dim strFileList As String
For Each swsFile In ActiveWorkbook.SharedWorkspace.Files
strFileList = "Filename: " & FilenameFromURL(swsFile.URL) & _
vbCrLf & " URL: " & URLDecode(swsFile.URL) & vbCrLf
Next
MsgBox strFileList, vbInformation + vbOKOnly, "Files in Shared Workspace"
Set swsFile = Nothing
Private Function FilenameFromURL(FileURL As String) As String
Dim intLastSeparator As Integer
FileURL = URLDecode(FileURL)
intLastSeparator = InStrRev(FileURL, "/")
FilenameFromURL = Right(FileURL, Len(FileURL) - intLastSeparator)
End Function
Private Function URLDecode(URLtoDecode As String) As String
URLDecode = Replace(URLtoDecode, "%20", " ")
End Function
As it applies to the SharedWorkspaceLink object.
The following example locates all links to the Microsoft Developer Network (MSDN) web site in the SharedWorkspaceLinks collection by examining the URL property of each link for the string "msdn".
Dim strMSDNLinks As String
Dim swsLink As Office.SharedWorkspaceLink
For Each swsLink In ActiveWorkbook.SharedWorkspace.Links
If InStr(swsLink.URL, "msdn", vbTextCompare) > 0 Then
strMSDNLinks = strMSDNLinks & swsLink.URL & vbCrLf
End If
Next
MsgBox "MSDN Links: " & vbCrLf & strMSDNLinks, _
vbInformation + vbOKOnly, "MSDN Links in Shared Workspace"