Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

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.

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/333ebbbcd7124837852571b900619cc1.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1