DocumentLibrary Object


Represents the collection of documents in the current Web site.
This object is supported only by Web pages or sites that are based on Microsoft SharePoint Services.
Using the DocumentLibrary object
Use Lists.Item(index), where index is either the name of the document library or its numeric position within the collection, to return a single DocumentLibrary object. The following example displays the names of all document libraries in the active Web site. If the Web site contains no document libraries, a message is displayed to the user.
Sub ListAllLibraries()
'Displays the names of all document libraries
'in the collection.
Dim lstWebList As List
Dim strName As String
Dim blnFound As Boolean
'Set found flag to false
blnFound = False
'Check if any lists exist and is so, cycle through them
If Not ActiveWeb.Lists Is Nothing Then
For Each lstWebList In ActiveWeb.Lists
If lstWebList.Type = fpListTypeDocumentLibrary Then
'Set boolean flag to found and add name to string
blnFound = True
If strName = "" Then
strName = lstWebList.Name & vbCr
Else
strName = strName & lstWebList.Name & vbCr
End If
End If
Next
If blnFound = True Then
'Display names of all document libraries
MsgBox "The names of all document libraries in the current web site are:" _
& vbCr & strName
Else
MsgBox "There are no document libraries in the current web site."
End If
Else
'Otherwise display message to user
MsgBox "The current web contains no lists."
End If
End Sub
Use the List object's Add method to create a new list of type fpListTypeDocumentLibrary. The following example creates a new document library called Newlibrary.
Sub NewLibrary()
'Adds a new list to the current web site
Dim objApp As FrontPage.Application
Dim objLists As Lists
Set objApp = FrontPage.Application
Set objLists = objApp.ActiveWeb.Lists
'Add new list
objLists.Add Name:="NewLibrary", _
ListType:=fpListTypeDocumentLibrary, _
Description:="List of Shared files"
'Display message to user
MsgBox "A new library was added to the Lists collection."
End Sub