Access File Properites

rmdrye

Registered User.
Local time
Today, 16:55
Joined
Aug 19, 2001
Messages
10
I would like to programmatically add File Properties (Title, Author, Subject, Comments) to Access files that my application is generating. Does anyone know the correct Object Model / Syntax to use to do this?
 
Excel workbook?
 
The following code will change the existing "Author" property of the database.   If the property doesn't exist, one will be created.
Code:
Private Sub Command0_Click()
  
  Dim db As DAO.Database
  Dim cnt As DAO.Container
  Dim doc As DAO.Document
  Dim prt As DAO.Property
  
  Set db = CurrentDb
  Set cnt = db.Containers!Databases
  Set doc = cnt.Documents!summaryinfo
      
  On Error Resume Next
  doc.Properties("Author") = "John Doe"
  
  ' if property not found, create it.
  If Err = 3270 Then
    Set prt = db.CreateProperty("Author", dbText, "John Doe")
    doc.Properties.Append prt
  End If

End Sub

You can add similar code for the other properties.

The code was written in Access 97, so DAO was used.   To write the code in Access 2000 or 2002, you must make a reference to DAO (when the code window is open, choose menu Tools, References... and select the Microsoft DAO 3.6 Object Library from the Available list.)
 

Users who are viewing this thread

Back
Top Bottom