OleGetProperty (OpenInsight 32-Bit)
At 28 JUL 2006 01:46:11PM John Bouley wrote:
How do you reference a collection using OleGetProperty. Specifically I need to access the second document in a Documents collection.
vb example:
Set owrdApp=CreateObject("Word.Application")
Set owrdDoc=owrdApp.Documents.Open(strMainDoc)
owrdDoc.MailMerge.Execute 0
owrdApp.Documents(1).PrintOut False ' (1) used as the 2'nd element.
OI example:
owrdApp=OLECreateInstance("Word.Application")
owrdDoc=OleGetProperty( owrdApp, 'Documents')
thisDoc=OleCallMethod(owrdDoc, "Open", strMainDoc)
mailMerge=oleGetProperty( thisDoc, "MailMerge")
val=oleCallMethod(mailMerge,"Execute", 0)
doc1=oleGetProperty(owrdApp,"Documents",1) *;this line doesn't work
val=oleCallMethod(doc1,"PrintOut", false)
The problem is doc1 is never assigned a value. I think I have the correct syntax eventhough the documentation does not show a 3rd parm on olegetproperty there are examples on the works for Excel.
How do I reference the second element in the Documents collection?
Thanks,
John
At 28 JUL 2006 01:56PM John Bouley wrote:
Posted too soon
here is the answer…
docs=oleGetProperty(owrdApp,"Documents")
doc1=oleCallMethod(docs,"Item",1)
val=oleCallMethod(doc1,"PrintOut", false)
turns out "Item" is a Method not a property… the specific document is returned in the olecallmethod and can then be used in subsequent olecallmethods.
HTH.