External call to Word (as an object) to return a Custom property from a document

I

Ian B

I need to obtain a custom property value from an active word document using
VB6. Test code shown below:
In VBA:
Dim myProp As DocumentProperty
For Each myProp In ActiveDocument.CustomDocumentProperties
MsgBox myProp.Name
Next

In VB6
Errors on indicated line
Set oWord = GetObject(, "Word.Application")
Dim myProp As oWord.DocumentProperty <<<<<<<<<<<<<<<<<
For Each myProp In oWord.ActiveDocument.CustomDocumentProperties
MsgBox myProp.Name
Next

What have I forgotten?

TIA

Ian B
 
P

Peter Jamieson

DocumentProperty is a member of the Office object, not the Word Application
(or Document) object. I don't have my copy of VB to hand but you probably
need to add a reference to the Office object and use something like

Dim oProp As New Office.DocumentProperty

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top