G
Guest
How do I invoke a Word method on Words' thread, instead of on my app's thread?
Background:
My VB.NET app automates Word (2000 and onwards). After I do some editing
(successfully) on a Word.Document object, I then call the document object's
Save method, but it produces the following COMException: "The Save method or
property is not available because this document is in another application."
I have had numerous similiar COMExceptions when my Word event handlers (in
my app) attempt to call methods in my app. The way in which I resolved these
exceptions was modify these calls to invoke my app's methods via a delegate
using the Control.Invoke method. I understand this runs my app's methods on
my app's thread instead of on the Word thread. But this time, I figure I need
to do the opposite (run a Word method on a Word thread) - but how do I do
this since there is no Invoke method available on any of the Word objects?
Thanks in advance for your help!
Background:
My VB.NET app automates Word (2000 and onwards). After I do some editing
(successfully) on a Word.Document object, I then call the document object's
Save method, but it produces the following COMException: "The Save method or
property is not available because this document is in another application."
I have had numerous similiar COMExceptions when my Word event handlers (in
my app) attempt to call methods in my app. The way in which I resolved these
exceptions was modify these calls to invoke my app's methods via a delegate
using the Control.Invoke method. I understand this runs my app's methods on
my app's thread instead of on the Word thread. But this time, I figure I need
to do the opposite (run a Word method on a Word thread) - but how do I do
this since there is no Invoke method available on any of the Word objects?
Thanks in advance for your help!