1. David Vasconcelos
  2. PowerBuilder
  3. Friday, 21 May 2021 17:42 PM UTC

Is there a way to see if the ole object is still connected.  I have an issue where MS Word is opened using OLE and if word shuts down abruptly the ole object is still active but if any command is issued using the oleobject then we get an error.  

Dave V.

 

PB2017R3, Office Pro.

 

John Fauss Accepted Answer Pending Moderation
  1. Friday, 21 May 2021 18:36 PM UTC
  2. PowerBuilder
  3. # 1

This is one reason I always code ALL of my OLE code within TRY...CATCH blocks.

Comment
  1. David Vasconcelos
  2. Friday, 21 May 2021 20:09 PM UTC
So I guess there is no "IsConnected" or anyother way to easily check. I am wrapping it with try catch but having issues with that also. Have another issue I entered just now. I am getting error popups even thought I have the ole wrapped in a catch try block.
  1. Helpful
  1. John Fauss
  2. Friday, 21 May 2021 21:14 PM UTC
Can you be a little more specific, please? What error(s)? What RuntimeError class do you use in your OLE Try-Catch blocks? I use OLERuntimeError, which is a descendant of the RuntimeError class. The OLERuntimeError class contains some additional properties/information. See the PB Help topic: RuntimeError Object.



Please note in this documentation that the OLERuntimeError object is thrown "...when an OLE error occurs that is not handled by an ocx_error, ExternalException, or Error event script." You can create a new user object inherited from the oleobject standard class - There you can code/handle the Error & ExternalException event scripts.



The OLEObject object provides a GetAutomationNativePointer(unsignedlong) function (returns integer) which the documentation says returns a pointer to the underlying OLE object. I've not used this property, but it might be used to tell you something useful in your case. There is also an IsAlive() property (returns boolean) that determines whether a server object is "defunct". Check out the help for the OLEObject object. Good luck!
  1. Helpful
  1. David Vasconcelos
  2. Wednesday, 2 June 2021 15:40 PM UTC
Thanks, John... the IsAlive property is what I needed.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.