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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE error trap on bad URL

Status
Not open for further replies.

Jerz

MIS
Sep 10, 2004
102
US
I'm needing help automating some downloads, and I can't seem to get IE to tell me whether the requested path is valid. I'm adding one to our current definition value, and checking for the presence of the file on the website with:
Code:
On error resume next
set x = createobject("internetexplorer.application")
x.navigate "[URL unfurl="true"]http://download.nai.com/products/datfiles/4.x/nai/dat-4726.zip"[/URL]
wscript.echo Err.number
x.quit
set x = nothing
err.clear

Err.number is always 0, if the file exists or not. :(
Any tips or other aproaches would be welcome.
 
In this case, you need to use ie event model, in particular, you monitor the navigateerror event. For this purpose, you need to instantiate with wscript-hosted engine.
[tt]
'z_ is just some prefix, quite arbitrary
set x = [blue]wscript.[/blue]createobject("internetexplorer.application"[blue],"z_"[/blue])
x.navigate "wscript.echo Err.number
x.quit
set x = nothing
err.clear

[blue]sub z_navigateerror(a,b,c,d,e)
wscript.echo d
end sub[/blue]
[/tt]
The navigateerror event is documented here.
You can pass back the statuscode to control process flow. It's up to your imagination.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top