Hi Neopa
Yes I normally use option explict, but the code is something that I threw together in about 15 minutes, for the sole purpose of answering the posted question. So to answer your question I did not use Option explicit and the posted code is complete.
I hope I can be forgiven for the bad programming practice because, I can try and excuse it with the simplicity of the program but there is no excuse in reality :{
No offence is taken, you are just....right!
As to the "Microsoft Internet Controls" library, that is definitely the one.
I also have a reference to the "Microsoft HTML Object" Library, so I tried removing the reference to the "Microsoft Internet Controls" and then checked intellisense by typing a space immediately after "As" in
Private ieBrowser As InternetExplorer
and there was no InternetExplorer in the list.
so its definitely "Microsoft Internet Controls"
The code is actually written from ideas presented on a few sites I found with google. Much of the code was copy paste as evidenced by the variable you point out sDocHTML. My normal practice would have it as strDocHTML
Anyway, here is a cleaned up version of the code
-
Option Compare Database
-
Option Explicit
-
-
Private ieBrowser As InternetExplorer
-
-
Private Sub Form_Load()
-
Dim strDocHTML As String, dteStartTime As Date
-
'Create a browser object
-
Set ieBrowser = CreateObject("internetexplorer.application")
-
ieBrowser.Navigate "http://www.delerna.com/Index.asp"
-
-
'Wait for the page to load. Exit Form_load sub, doing nothing, if loading the page takes too long
-
dteStartTime = Now
-
Do While ieBrowser.readyState <> READYSTATE_COMPLETE
-
If DateDiff("s", dteStartTime, Now) > 240 Then Exit Sub
-
Loop
-
-
'Get the page contents
-
strDocHTML = ieBrowser.Document.documentElement.innerHTML
-
-
'And save it
-
Open "c:\Test.txt" For Output As 1
-
Print #1, strDocHTML
-
Close #1
-
-
'destroy the browser object
-
Set ieBrowser = Nothing
-
End Sub
-