Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default MSHTML Objects

Dear Sirs,

I am trying to download a csv file from the internet using
the MSHTML model and can successfully obtain the data to a
HTMLDocument variable using the following.

Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument

Set objDocument = objMSHTML.createDocumentFromUrl
(txtURL.Text, vbNullString)

where txtURL.Text
= "http://www.a_web_site.com/download/data.csv"

What I cannot do is extract the csv data from the
variable, as it does not appear to be associated with any
node / element etc.

I know the objDocument does contain the data as I can
check the size of the variable to which it returns a
largeish value

I am really quite lost with all this - I do not really
understand how all this works and have been trying to find
an online resource that explains it in lay terms, however
everything that I have located to date goes way over my
head!

Hoping someone can assist

Regards

Jack
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default MSHTML Objects

Hi,
have you seen this :

From: "Dave"
References:
Subject: Download file from URL with password
Date: Tue, 8 Feb 2005 13:58:40 -0500
Newsgroups: microsoft.public.excel.programming

If you have a reference to MSHTML than have you tried already :

Dim myPage As HTMLDocument
'sBuffer string which holds the HTML
Dim sBuffer As String
'Capture all the text in the storage a buffer :
'
sBuffer = myPage.body.innerHTML

Than you could try to write the srting to Excel

hth
Gys



"Jack Clift" wrote in message
...
Dear Sirs,

I am trying to download a csv file from the internet using
the MSHTML model and can successfully obtain the data to a
HTMLDocument variable using the following.

Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument

Set objDocument = objMSHTML.createDocumentFromUrl
(txtURL.Text, vbNullString)

where txtURL.Text
= "http://www.a_web_site.com/download/data.csv"

What I cannot do is extract the csv data from the
variable, as it does not appear to be associated with any
node / element etc.

I know the objDocument does contain the data as I can
check the size of the variable to which it returns a
largeish value

I am really quite lost with all this - I do not really
understand how all this works and have been trying to find
an online resource that explains it in lay terms, however
everything that I have located to date goes way over my
head!

Hoping someone can assist

Regards

Jack


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default MSHTML Objects

the code:

sBuffer = myPage.body.innerHTML

will only work if the data is 'attached' to a 'body'
element, which it is not in my case.

Any other ideas?


-----Original Message-----
Hi,
have you seen this :

From: "Dave"
References: <AF38F843-798B-438C-9A85-


Subject: Download file from URL with password
Date: Tue, 8 Feb 2005 13:58:40 -0500
Newsgroups: microsoft.public.excel.programming

If you have a reference to MSHTML than have you tried

already :

Dim myPage As HTMLDocument
'sBuffer string which holds the HTML
Dim sBuffer As String
'Capture all the text in the storage a buffer :
'
sBuffer = myPage.body.innerHTML

Than you could try to write the srting to Excel

hth
Gys



"Jack Clift" wrote

in message
...
Dear Sirs,

I am trying to download a csv file from the internet

using
the MSHTML model and can successfully obtain the data

to a
HTMLDocument variable using the following.

Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument

Set objDocument = objMSHTML.createDocumentFromUrl
(txtURL.Text, vbNullString)

where txtURL.Text
= "http://www.a_web_site.com/download/data.csv"

What I cannot do is extract the csv data from the
variable, as it does not appear to be associated with

any
node / element etc.

I know the objDocument does contain the data as I can
check the size of the variable to which it returns a
largeish value

I am really quite lost with all this - I do not really
understand how all this works and have been trying to

find
an online resource that explains it in lay terms,

however
everything that I have located to date goes way over my
head!

Hoping someone can assist

Regards

Jack


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default MSHTML Objects

Try this - add reference to MSXML and ADO libraries.

Tim.

Sub SaveFileFrom Web(sURL As String, sPath As String)
Dim oXHTTP As New MSXML2.XMLHTTP
Dim oStream As New ADODB.Stream

Application.StatusBar = "Fetching " & sURL & " as " & sPath

oXHTTP.Open "GET", sURL, False
oXHTTP.send

with oStream
.Type = adTypeBinary
.Open
.Write oXHTTP.responseBody
.SaveToFile sPath, adSaveCreateOverWrite
.Close
end with

Set oXHTTP = Nothing
Set oStream = Nothing

End Sub




"Jack Clift" wrote in message
...
the code:

sBuffer = myPage.body.innerHTML

will only work if the data is 'attached' to a 'body'
element, which it is not in my case.

Any other ideas?


-----Original Message-----
Hi,
have you seen this :

From: "Dave"
References: <AF38F843-798B-438C-9A85-


Subject: Download file from URL with password
Date: Tue, 8 Feb 2005 13:58:40 -0500
Newsgroups: microsoft.public.excel.programming

If you have a reference to MSHTML than have you tried

already :

Dim myPage As HTMLDocument
'sBuffer string which holds the HTML
Dim sBuffer As String
'Capture all the text in the storage a buffer :
'
sBuffer = myPage.body.innerHTML

Than you could try to write the srting to Excel

hth
Gys



"Jack Clift" wrote

in message
...
Dear Sirs,

I am trying to download a csv file from the internet

using
the MSHTML model and can successfully obtain the data

to a
HTMLDocument variable using the following.

Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument

Set objDocument = objMSHTML.createDocumentFromUrl
(txtURL.Text, vbNullString)

where txtURL.Text
= "http://www.a_web_site.com/download/data.csv"

What I cannot do is extract the csv data from the
variable, as it does not appear to be associated with

any
node / element etc.

I know the objDocument does contain the data as I can
check the size of the variable to which it returns a
largeish value

I am really quite lost with all this - I do not really
understand how all this works and have been trying to

find
an online resource that explains it in lay terms,

however
everything that I have located to date goes way over my
head!

Hoping someone can assist

Regards

Jack


.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default MSHTML Objects

Hi Jack,

I know the objDocument does contain the data as I can
check the size of the variable to which it returns a
largeish value


The easiest way to find your way around the object model is to step
through the code with the Locals window showing. Once you've opened the
URL and allowed the content to download, expand the objDocument node to
see it's contents. Hopefully, one of the properties will expose your
csv data.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OLE Objects [email protected] Excel Discussion (Misc queries) 0 March 7th 08 09:44 PM
VBA Objects Kevin Excel Discussion (Misc queries) 8 January 1st 05 09:07 PM
Dynamically Assign Objects to Form Objects. The Vision Thing Excel Programming 2 December 11th 04 04:02 PM
Unable to remove Sheet objects in the Microsoft Excel Objects Adrian[_7_] Excel Programming 1 August 26th 04 10:49 PM
deleting objects using VBA cweijden Excel Programming 1 November 26th 03 03:45 PM


All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"