Reference to IE - but none found?

Q

quartz

I have some code, I think developed for Excel 97 that requires a reference to
MS Internet Explorer. The problem is, I don't have a library for IE. Has it
been changed? Can I download it from somewhere?

OR, better still, can someone update the following code for XP?

Sub FindImages(sURL As String)

Dim oDoc As New MSHTML.HTMLDocument
Dim IE As New InternetExplorer
Dim i As Integer

IE.navigate sURL
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Set oDoc = IE.Document
For i = 1 To oDoc.images.Length
If oDoc.images(i - 1).src Like "http://ichart.yahoo.com/*" Then
saveImg oDoc.images(i - 1).src, ThisWorkbook.Path & "\temp.png"
End If
Next i
Set oDoc = Nothing
Set IE = Nothing
End Sub

Thanks in advance.
 
J

Jake Marx

Hi quartz,

The reference you need for the InternetExplorer object is "Microsoft
Internet Controls". Or you could use Late Binding by declaring both object
variables As Object and using CreateObject instead of the New keyword. If
you decide to use Late Binding, you'll also have to replace the constant
READYSTATE_COMPLETE with its literal value, which is 4.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Q

quartz

Whoa! Thanks Jake.

This sub calls another as follows:

Sub saveImg(sURL As String, sPath As String)

Dim oXHTTP As New MSXML2.XMLHTTP
Dim oStream As New ADODB.Stream
Dim oFSO As New Scripting.FileSystemObject
oXHTTP.Open "GET", sURL, False
oXHTTP.send
oStream.Type = adTypeBinary
oStream.Open
oStream.Write oXHTTP.responseBody
oStream.SaveToFile sPath, adSaveCreateOverWrite
oStream.Close
Set oXHTTP = Nothing
Set oStream = Nothing
Set oFSO = Nothing

End Sub

Can you tell me where I could find illustrative examples on how to code
using "Streams" and IE?

Again thanks for the assistance.

Jake Marx said:
Hi quartz,

The reference you need for the InternetExplorer object is "Microsoft
Internet Controls". Or you could use Late Binding by declaring both object
variables As Object and using CreateObject instead of the New keyword. If
you decide to use Late Binding, you'll also have to replace the constant
READYSTATE_COMPLETE with its literal value, which is 4.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

I have some code, I think developed for Excel 97 that requires a
reference to MS Internet Explorer. The problem is, I don't have a
library for IE. Has it been changed? Can I download it from somewhere?

OR, better still, can someone update the following code for XP?

Sub FindImages(sURL As String)

Dim oDoc As New MSHTML.HTMLDocument
Dim IE As New InternetExplorer
Dim i As Integer

IE.navigate sURL
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Set oDoc = IE.Document
For i = 1 To oDoc.images.Length
If oDoc.images(i - 1).src Like "http://ichart.yahoo.com/*" Then
saveImg oDoc.images(i - 1).src, ThisWorkbook.Path & "\temp.png"
End If
Next i
Set oDoc = Nothing
Set IE = Nothing
End Sub

Thanks in advance.
 
J

Jake Marx

Hi quartz,

I don't know of any resources offhand (besides the MSDN/MS sites). My
understanding of XMLHTTP code came mainly from results of Google searches.
It's a popular technology for the ASP folks, so you may want to look around
some ASP sites for more examples.

Here's an example I posted back in June 2002 that does a generic file copy
over HTTP, if it helps any:

http://groups-beta.google.com/group...read/thread/d86562f72b3775a4/8b93dbf506ee96fd

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Whoa! Thanks Jake.

This sub calls another as follows:

Sub saveImg(sURL As String, sPath As String)

Dim oXHTTP As New MSXML2.XMLHTTP
Dim oStream As New ADODB.Stream
Dim oFSO As New Scripting.FileSystemObject
oXHTTP.Open "GET", sURL, False
oXHTTP.send
oStream.Type = adTypeBinary
oStream.Open
oStream.Write oXHTTP.responseBody
oStream.SaveToFile sPath, adSaveCreateOverWrite
oStream.Close
Set oXHTTP = Nothing
Set oStream = Nothing
Set oFSO = Nothing

End Sub

Can you tell me where I could find illustrative examples on how to
code using "Streams" and IE?

Again thanks for the assistance.

Jake Marx said:
Hi quartz,

The reference you need for the InternetExplorer object is "Microsoft
Internet Controls". Or you could use Late Binding by declaring both
object variables As Object and using CreateObject instead of the New
keyword. If you decide to use Late Binding, you'll also have to
replace the constant READYSTATE_COMPLETE with its literal value,
which is 4.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

I have some code, I think developed for Excel 97 that requires a
reference to MS Internet Explorer. The problem is, I don't have a
library for IE. Has it been changed? Can I download it from
somewhere?

OR, better still, can someone update the following code for XP?

Sub FindImages(sURL As String)

Dim oDoc As New MSHTML.HTMLDocument
Dim IE As New InternetExplorer
Dim i As Integer

IE.navigate sURL
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Set oDoc = IE.Document
For i = 1 To oDoc.images.Length
If oDoc.images(i - 1).src Like "http://ichart.yahoo.com/*" Then
saveImg oDoc.images(i - 1).src, ThisWorkbook.Path &
"\temp.png" End If
Next i
Set oDoc = Nothing
Set IE = Nothing
End Sub

Thanks in advance.
 
Q

quartz

Okay. Thanks again.

Jake Marx said:
Hi quartz,

I don't know of any resources offhand (besides the MSDN/MS sites). My
understanding of XMLHTTP code came mainly from results of Google searches.
It's a popular technology for the ASP folks, so you may want to look around
some ASP sites for more examples.

Here's an example I posted back in June 2002 that does a generic file copy
over HTTP, if it helps any:

http://groups-beta.google.com/group...read/thread/d86562f72b3775a4/8b93dbf506ee96fd

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

Whoa! Thanks Jake.

This sub calls another as follows:

Sub saveImg(sURL As String, sPath As String)

Dim oXHTTP As New MSXML2.XMLHTTP
Dim oStream As New ADODB.Stream
Dim oFSO As New Scripting.FileSystemObject
oXHTTP.Open "GET", sURL, False
oXHTTP.send
oStream.Type = adTypeBinary
oStream.Open
oStream.Write oXHTTP.responseBody
oStream.SaveToFile sPath, adSaveCreateOverWrite
oStream.Close
Set oXHTTP = Nothing
Set oStream = Nothing
Set oFSO = Nothing

End Sub

Can you tell me where I could find illustrative examples on how to
code using "Streams" and IE?

Again thanks for the assistance.

Jake Marx said:
Hi quartz,

The reference you need for the InternetExplorer object is "Microsoft
Internet Controls". Or you could use Late Binding by declaring both
object variables As Object and using CreateObject instead of the New
keyword. If you decide to use Late Binding, you'll also have to
replace the constant READYSTATE_COMPLETE with its literal value,
which is 4.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


quartz wrote:
I have some code, I think developed for Excel 97 that requires a
reference to MS Internet Explorer. The problem is, I don't have a
library for IE. Has it been changed? Can I download it from
somewhere?

OR, better still, can someone update the following code for XP?

Sub FindImages(sURL As String)

Dim oDoc As New MSHTML.HTMLDocument
Dim IE As New InternetExplorer
Dim i As Integer

IE.navigate sURL
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Set oDoc = IE.Document
For i = 1 To oDoc.images.Length
If oDoc.images(i - 1).src Like "http://ichart.yahoo.com/*" Then
saveImg oDoc.images(i - 1).src, ThisWorkbook.Path &
"\temp.png" End If
Next i
Set oDoc = Nothing
Set IE = Nothing
End Sub

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top