Accessing custom document properties

  • Thread starter Thread starter Tim Haley
  • Start date Start date
T

Tim Haley

Anyone know of a way to access and display the custom
document properties in Excel?

Thanks ...
 
Tim Haley said:
Anyone know of a way to access and display the custom
document properties in Excel?

Thanks ...


To iterate through all document properties and add them
to a list box

Dim dp As DocumentProperty

For Each dp In ActiveWorkbook.CustomDocumentProperties
ListBox1.AddItem dp.Name
Next dp


To create a new document property
Set dp = ActiveWorkbook.CustomDocumentProperties.Add(Name:="adpass",
LinkToContent:=False, _
Type:=msoPropertyTypeString, value:="")

To set an existing property

ActiveWorkbook.CustomDocumentProperties("adpass") = "Hello World"

To delete a document properties
Dim dp As DocumentProperty

For Each dp In ActiveWorkbook.CustomDocumentProperties
if dp.Name="adpass" then
dp.Delete
End If
Next dp

Keith
 
Thanks Keith ...

This will work fine. Too bad Microsoft doesn't support
built-in Excel functions that access custom document
properties like Word field tags. Job security for those of
us who know how to progam in VB I suppose!

Tim
 
Back
Top