Hi everyone, new to the forum.
I use VB a lot with my work and have created several .dotm for frequently used documents. Typically I use custom document properties (entered via a userform) to store simple information such as document number and title but also more specific information for each document type.
The userform can be launched and the specific properties changed by entering a new value in a text box. The trouble with this is that each text box in my userform is specifically linked to one custom document property, for example:
Dim DP As DocumentProperties
Set DP = ActiveDocument.CustomDocumentProperties
DP("Document Title").Value = DocumentTitleTxt.Value
The textbox is inherently linked to the specific "Document Title" property.
I would like to be able to launch a user form and have EVERY custom document property (name) contained within the active document added to a combobox via the .AddItem method. Then, a single text box would display the value of the property currently selected from the combobox.
Is this possible? This is something I would use as it would be much easier and quicker and apply to any word document that has a custom document property.
I'm thinking a simple For...Next type arrangement but I just can't define the 'unknown' document property. Something like:
Private Sub UserForm_Initialize()
Dim DP As DocumentProperties
Set DP = ActiveDocument.CustomDocumentProperties
For Each DP In ActiveDocument
ComboBox1.AddItem DP().Name
Next
End Sub
but obviously the above doesn't work... Would really appreciate any insight you may have.
Thanks