Document Object and Documents Collection Example

This example enumerates the Documents collection of the Tables container, and then enumerates the Properties collection of the first Document object in the collection.

Sub DocumentX()

   Dim dbsNorthwind As Database
   Dim docLoop As Document
   Dim prpLoop As Property

   Set dbsNorthwind = OpenDatabase("Northwind.mdb")

   With dbsNorthwind.Containers!Tables
      Debug.Print "Documents in " & .Name & " container"
      ' Enumerate the Documents collection of the Tables 
      ' container.
      For Each docLoop In .Documents
         Debug.Print "  " & docLoop.Name
      Next docLoop
      With .Documents(0)
         ' Enumerate the Properties collection of the first.
         ' Document object of the Tables container.
         Debug.Print "Properties of " & .Name & " document"
         On Error Resume Next
         For Each prpLoop In .Properties
            Debug.Print "  " & prpLoop.Name & " = " & _
               prpLoop
         Next prpLoop
         On Error GoTo 0
      End With
   End With

   dbsNorthwind.Close

End Sub