Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internet Explorer Object 2

Status
Not open for further replies.

dddenney

Programmer
Nov 29, 2000
41
US
I have an application that creates an instance of Internet Explorer as an object with the following lines of code:

mLookup_Address = ' &&or whatever
oIE = CREATEOBJECT('InternetExplorer.Application')
oIE.navigate(mLookup_Address)
oIE.visible = .t.

I need to know if the user closes this instance of IE either throught the File > Close or the Close button.

Is there a way to check whether the oIE object is still valid? If it is then I can just navigate to a new address. If not, then I need to create a new instance of IE. Any help you can provide is greatly appreciated. Thanks.

Dan
 
Hello.

You can try

objname = oIE.Name

This line should raise and error and you can intercept it:

ON ERROR DO error_handling
objname = oIE.Name
IF THISFORM.lasterror
&& create a new instance
ENDIF

and the error_handling routine can signal the error using a flag (a form's property -- I named it lasterror). It could be something like this:

PROCEDURE error_handling
Thisform.lasterror = .T.
ENDPROC

Hope this helps
Grigore Dolghin
Class Software
Bucharest, Romania
 
Thanks Grigore,

That did the trick. I appreciate your help.
 
Dear dddenney,
I think you had solved your problem.

still, i couldn't stop me for writing this. You can add a sigle if condition to reach your solution.
like
----
mLookup_Address = ' &&or whatever
IF TYPE('oIE.NAME')<>'C'
oIE = CREATEOBJECT('InternetExplorer.Application')
ENDIF
oIE.navigate(mLookup_Address)
oIE.visible = .t.

----

I hope this will be help ful.
 
Thanks, I never even thought about using the Type() function.
 
You could also simply use this:

IF VARTYPE(oIE)='X' && Indicates oIE is .NULL. (app was closed)
oIE=CREATEOBJECT('InternetExplorer.Application')
ENDIF
 
Hmm...quite strange, it looks like IE responds a bit different than I thought. Issuing VARTYPE(oIE) or a TYPE('oIE') will still return type 'O' after the window is closed. Issuing VARTYPE(oIE.caption) generates an error message (&quot;The object invoked has disconnected from its clients&quot;)...but if you use TYPE('oIE.caption') it returns 'U'.

*shrugs* Makes no sense to me, but my above suggestion doesn't work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top