I encountered these while browsing a document a long time ago and in what felt like another galaxy. However, I gave it a look, and indeed they are present. So....
I set up a macro recording session to capture the steps necessary.
NOTHING
OK, let's take a look at the object model for Document. Sure enough there is CustomDocumentProperties (nothing about non-custom DocumentProperties). No type given, just Object. Really helpful. However, in the model (using F2) there are entries for CustomProperties, Custom Property, DocumentProperties and DocumentProperty.
OK, not too many possibilities, let's throw some code at it:
It ran - and found the single custom property I had created manually (while trying to record the macro). OK, Let's redeclare PPInstance as a CustomProperty:
OK - an entry in CustomDocumentProperties does indeed seem to be a DocumentProperty. Let's see if we can change the values:
Glory be! It works. Only problem is that I have to create the CustomProperty manually. I wonder if I can add an entry.
(Short cut)
Browsing the MSDN site for info on this, I got:
Hmm, I read the Type value as an integer, but it wants an Object? Turns out there are objects to specify the type (a simnple constant would be fartoo easy, I guess.
The description under the example in MSDN says msoPropertyTypeString should work.
The Add fails with an automation error (long negative number signifying nothing).
I'm stumped - perhaps it's time for an adult beverage. If anyone has any ideas, or has done this before, some code examples would be great......
Tony
Bookmarks