Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Web Query in Excel

Hi folks. This is an area that I am not familiar with at all. I am
trying to query a web page from excl:

http://ets.powerpool.ab.ca/Market/Re...DReportServlet

What I want is to dump the data from the tables into Sheet1 cell A1. I
originally attempted to do this manually by going to Data/Import
Data/New Web Query. I put the address in the address window, clicked
the boxes next to the tables I wanted and hit Import. I get an error
message say the web query returned no data.

A colleague of mine told me that the reason it does not work is that
the HTML code has a line in it (line 3) that says:

<pThe report is downloading, please wait...</p

As such the query is failing due to this line of code. Firstly I need
to figure out why this is not working manually. Upon figuring that
out, I need to write VBA code which will undetake this task - updating
every 5 minutes. That is I want it to paste the desired table to the
same excel cell destination every 5 minutes.

Any help would be appreciated.

Thank-you


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Web Query in Excel

Hi ExcelMonkey ,

I think your colleague is correct. That div and the javascript code is
causing Excel some problems.

Here's a workaround that may work for you. Below is a subroutine I wrote to
grab the HTML from a URL and save the resulting document to a local path,
modifying the HTML to remove the offending parts. There's no error
handling, so you may want to add that.

You could call this sub every 5 minutes using Application.OnTime. You can
then set up your web query to point to the local file and set it to
automatically refresh every 5 minutes, too.

Public Sub GenerateLocalHTML(rsURL, rsTargetPath)
Dim xml As Object
Dim fso As Object
Dim lHeadPos As Long
Dim sBase As String
Dim sHTML As String

Set xml = CreateObject("Microsoft.XMLHTTP")

With xml
.Open "GET", rsURL
.send
sHTML = .responseText
End With

Set xml = Nothing

If Len(sHTML) Then
'/ set base URL for images
lHeadPos = InStr(1, sHTML, "<head", vbTextCompare)
If lHeadPos Then
sBase = Left$(rsURL, InStr(InStr(1, rsURL, "//") _
+ 2, rsURL, "/") - 1)
sHTML = "<html<head<base href=""" & sBase & """" _
& Mid$(sHTML, lHeadPos + 6)
End If
'/ create file
Set fso = CreateObject("Scripting.FileSystemObject")
With fso.CreateTextFile(rsTargetPath, True)
.Write sHTML
.Close
End With
Set fso = Nothing
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

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


Hi folks. This is an area that I am not familiar with at all. I am
trying to query a web page from excl:

http://ets.powerpool.ab.ca/Market/Re...DReportServlet

What I want is to dump the data from the tables into Sheet1 cell A1.
I originally attempted to do this manually by going to Data/Import
Data/New Web Query. I put the address in the address window, clicked
the boxes next to the tables I wanted and hit Import. I get an error
message say the web query returned no data.

A colleague of mine told me that the reason it does not work is that
the HTML code has a line in it (line 3) that says:

<pThe report is downloading, please wait...</p

As such the query is failing due to this line of code. Firstly I need
to figure out why this is not working manually. Upon figuring that
out, I need to write VBA code which will undetake this task - updating
every 5 minutes. That is I want it to paste the desired table to the
same excel cell destination every 5 minutes.

Any help would be appreciated.

Thank-you


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Web Query in Excel

Note that the help for the page says it refreshes every 10 minutes, so 5
minutes may be too frequent.

--
Regards,
Tom Ogilvy

"Jake Marx" wrote in message
...
Hi ExcelMonkey ,

I think your colleague is correct. That div and the javascript code is
causing Excel some problems.

Here's a workaround that may work for you. Below is a subroutine I wrote

to
grab the HTML from a URL and save the resulting document to a local path,
modifying the HTML to remove the offending parts. There's no error
handling, so you may want to add that.

You could call this sub every 5 minutes using Application.OnTime. You can
then set up your web query to point to the local file and set it to
automatically refresh every 5 minutes, too.

Public Sub GenerateLocalHTML(rsURL, rsTargetPath)
Dim xml As Object
Dim fso As Object
Dim lHeadPos As Long
Dim sBase As String
Dim sHTML As String

Set xml = CreateObject("Microsoft.XMLHTTP")

With xml
.Open "GET", rsURL
.send
sHTML = .responseText
End With

Set xml = Nothing

If Len(sHTML) Then
'/ set base URL for images
lHeadPos = InStr(1, sHTML, "<head", vbTextCompare)
If lHeadPos Then
sBase = Left$(rsURL, InStr(InStr(1, rsURL, "//") _
+ 2, rsURL, "/") - 1)
sHTML = "<html<head<base href=""" & sBase & """" _
& Mid$(sHTML, lHeadPos + 6)
End If
'/ create file
Set fso = CreateObject("Scripting.FileSystemObject")
With fso.CreateTextFile(rsTargetPath, True)
.Write sHTML
.Close
End With
Set fso = Nothing
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

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


Hi folks. This is an area that I am not familiar with at all. I am
trying to query a web page from excl:

http://ets.powerpool.ab.ca/Market/Re...DReportServlet

What I want is to dump the data from the tables into Sheet1 cell A1.
I originally attempted to do this manually by going to Data/Import
Data/New Web Query. I put the address in the address window, clicked
the boxes next to the tables I wanted and hit Import. I get an error
message say the web query returned no data.

A colleague of mine told me that the reason it does not work is that
the HTML code has a line in it (line 3) that says:

<pThe report is downloading, please wait...</p

As such the query is failing due to this line of code. Firstly I need
to figure out why this is not working manually. Upon figuring that
out, I need to write VBA code which will undetake this task - updating
every 5 minutes. That is I want it to paste the desired table to the
same excel cell destination every 5 minutes.

Any help would be appreciated.

Thank-you


---
Message posted from http://www.ExcelForum.com/




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Web Query in Excel

Thanks I will give it a try

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Web Query in Excel

Hey Jake, I tried the code. My Norton antivirus detected it an
starting popping up alerts regarding suspicious code. I disabled i
and when it ran, it failed with an error statement saying permissio
denied. What happened?

Thank

--
Message posted from http://www.ExcelForum.com



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
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Query from microsoft query- Excel 2007 טבלאות אקסל 2007 Excel Discussion (Misc queries) 0 December 24th 07 10:47 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 07:33 PM.

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

About Us

"It's about Microsoft Excel"