Again, many thanks!

You could have just said "...and I covered that on page 123 of my book. Pick up a copy!" but you didn't. :)

Mike

-------- Original Message --------
Subject: Re: Print A Word Document From VFP
From: Ted Roche <[email protected]>
To: [email protected]
Date: 5/10/2013 1:43 PM
On Fri, May 10, 2013 at 1:58 PM, Mike Copeland <[email protected]> wrote:


Okay, first, honors to The Great Ted for this...it's like the last piece
of a puzzle that makes everything complete.

Aw, shucks.

And just to make sure I understand why this helps, my guess is that
GETOBJECT() creates a pointer to the existing, activated OLE app, and
therefore it prevents the OLE app from responding in the same way as it
would by direct interaction. Please correct me if that's wrong (probably
not 100% on target, but...)

Yes, my understanding is that, depending on the OLE interface that's
implemented, CreateObject() invokes a new EXE to talk to (starting a new
conversation), while GetObject() attempts to communicate with an existing,
running executable.

I suspect that what you REALLY want to do is... (pseudocode, will not
compile)

oWord = CreateObject(Word.Application)
start loop...
oDoc = oWord.Open(MyExistingDoc.Doc)
oDoc.Print()
... pause ....
oDoc.Close(WithoutSaveChangesDialog)
end loop
oWord.Close, Clear, Release, whichever's appropriate.

But as I've already disclaimed, Automation was a dozen years ago, and I
gave up on writing Automation code around the third time MS broke the
backwards-compatible interfaces.

Would it be good practice, to prevent consuming more and more memory, to
release the GETOBJECT() reference after the document is printed (and before
you iterate for the next document)?


If GetObject getting released causes the EXE to collapse, so the
next invocation requires reloading the EXE, no, that would be less
efficient. IIRC, different Office apps behave(d) differently. Did I mention
there's a book you ought to review <g>?



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to