I use the following subroutine to produce document lists for my various
databases.
I have a table named tblDocuments with a 2 columns, one for the document
name and another for its container. The code opens the table as recordset
object and the uses a FOR loop to loop through each container, and within
each container, each document, posting the document name in the first field
and the container name in the second. You could then export the table to
Excel or query it from Excel using MS Query.
Sub ContainerContents()
Dim dbs As DAO.Database
Dim rst As DAO.RecordSet
Dim con As Container
Dim doc As Document
Dim strDocName As String
Dim strConName As String
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblDocuments")
For Each con In dbs.Containers
strConName = con.Name
For Each doc In con.Documents
strDocName = doc.Name
With rst
.AddNew
.Fields(0).Value = strDocName
.Fields(1).Value = strConName
.Update
End With
Next doc
Next con
rst.Close
Set dbs = Nothing
Set rst = Nothing
Set con = Nothing
Set doc = Nothing
End Sub