Web interaction

  • Thread starter Thread starter Nigel
  • Start date Start date
N

Nigel

Hi All,
The following code (test) is being set up to establish a web link, I have
the following question about the code if anyone can help much appreciated.

1. How can I test if the internet explorer object is open / ready ? - for
example I create the ie object and then quit ie and set ie to nothing is
there a way of testing if the object exists, eg

If ie then
do this
else
do this
endif

2. On another note is it valid to test if the ie object exists before it is
created?

3. The 'wait for response' could wait a long time, how can I set a limit on
the time ? Does the Do Events statement inside the loop allow me to have
another userform control event activate, such as a cancel button to force
the ie activty to stop

TIA
Cheers
Nigel


Sub WebLink()

Set ie = CreateObject("InternetExplorer.Application")
MsgBox "IE Created"

sURL = "http://www.foo.com"

ie.Navigate sURL

'wait for response
Do Until Not ie.Busy And ie.ReadyState = 4
DoEvents
Loop

'close ie and remove memory references
ie.Quit
Set ie = Nothing

End Sub
 
Hi
try something like the following


On Error Resume Next
AppActivate "Internet Explorer"
If Err.Number <> 0 Then
msgbox "Internet Explorer is not running"
else
msgbox "IE is running"
End If
 
Thanks, Frank
-----Original Message-----
Hi
try something like the following


On Error Resume Next
AppActivate "Internet Explorer"
If Err.Number <> 0 Then
msgbox "Internet Explorer is not running"
else
msgbox "IE is running"
End If



--
Regards
Frank Kabel
Frankfurt, Germany


.
 
Nigel,
Look into the difference between GetObject and CreateObject.

Also you can use: If MyObject Is Nothing Then
to see if your reference is pointing to a valid object.

NickHK

Nigel said:
Hi All,
The following code (test) is being set up to establish a web link, I have
the following question about the code if anyone can help much appreciated.

1. How can I test if the internet explorer object is open / ready ? - for
example I create the ie object and then quit ie and set ie to nothing is
there a way of testing if the object exists, eg

If ie then
do this
else
do this
endif

2. On another note is it valid to test if the ie object exists before it is
created?

3. The 'wait for response' could wait a long time, how can I set a limit on
the time ? Does the Do Events statement inside the loop allow me to have
another userform control event activate, such as a cancel button to force
the ie activty to stop

TIA
Cheers
Nigel


Sub WebLink()

Set ie = CreateObject("InternetExplorer.Application")
MsgBox "IE Created"

sURL = "http://www.foo.com"

ie.Navigate sURL

'wait for response
Do Until Not ie.Busy And ie.ReadyState = 4
DoEvents
Loop

'close ie and remove memory references
ie.Quit
Set ie = Nothing

End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top