Edit File Properties: Title, Subject, Keywords, (MetaData) w/ VBA

  • Thread starter Thread starter Benjamin
  • Start date Start date
B

Benjamin

I'd like to edit the Title, Subject, & Custom Properties of some files.
right now *.dwg & *.xls.

What's the object or API to use to access the files document properties.
(You know the ones where you right click a file and go to the custom or
summary tab and look at the metadata, i.e. Title, subject etc).

I'd like to to be able to retrieve the data as well as write to it.

Could someone help get me started in the right direction here.
 
As a starter..................but don't miss having a look at Chip's site
that gsnu200901 pointed you to.

Sub documentprops()
'list of properties on a new sheet
rw = 1
Worksheets.Add
For Each p In ActiveWorkbook.BuiltinDocumentProperties
Cells(rw, 1).Value = p.Name
Cells(rw, 4).Value = "=DocProps(" & "A" & rw & ")"
rw = rw + 1
Next
End Sub

Sub customprops()
'list of custom properties on a new sheet
rw = 1
Worksheets.Add
For Each p In ActiveWorkbook.CustomDocumentProperties
Cells(rw, 1).Value = p.Name
Cells(rw, 4).Value = p.Value
rw = rw + 1
Next
End Sub

Sub Add_Custom_Prop()
Dim dp As DocumentProperties
Set dp = ThisWorkbook.CustomDocumentProperties
dp.Add Name:="gordo", _
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=0
End Sub

Sub Add_One_To_Custom_Prop()
'add 1 to "gordo" value
If ActiveSheet.Name = "Sheet1" Then
N = ThisWorkbook.CustomDocumentProperties("gordo").Value
N = N + 1
ActiveSheet.PageSetup.RightHeader = N
ThisWorkbook.CustomDocumentProperties("gordo").Value = N
End If
ActiveSheet.PrintOut
End Sub


Gord Dibben MS Excel MVP
 
Back
Top