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

Hi,

I am trying to perform a webquery that grabs specific data from a page. I
want to grab only the data between two specific tags "<!--StartTag--" and
"<!--EndTag--"

Is there any way to do this? The webquery built into excel does not seem to
allow for this kind of specific parsing. Any help would be appreciated.

thanks,
dave


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

Hi Dave,

The following function will take a URL, a start string (in your case, pass
in "<!--StartTag--"), and an end string ("<!--EndTag--") and will retun
the HTML source inbetween them. If you want the actual text displayed on
the screen, then you can change InnerHTML to InnerText, but you will have to
use 2 visible text strings (not HTML comments) as the start and end
arguments.

Public Function gsGetString(rsURL As String, _
rsStartHTML As String, rsEndHTML As String) As String
Dim ie As Object
Dim sHTML As String
Dim lStartPos As Long
Dim lEndPos As Long

Set ie = CreateObject("InternetExplorer.Application")

With ie
.Navigate rsURL
Do Until Not .Busy And .ReadyState = 4
DoEvents
Loop
sHTML = .Document.Body.InnerHTML
End With

ie.Quit
Set ie = Nothing

lStartPos = InStr(1, sHTML, rsStartHTML, vbTextCompare)
If lStartPos Then
lStartPos = lStartPos + Len(rsStartHTML)
lEndPos = InStr(lStartPos, sHTML, rsEndHTML, vbTextCompare)
If lEndPos Then
lEndPos = lEndPos - 1
gsGetString = Mid$(sHTML, lStartPos, lEndPos _
- lStartPos + 1)
End If
End If
End Function

--
Regards,

Jake Marx
www.longhead.com

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


Daveed wrote:
Hi,

I am trying to perform a webquery that grabs specific data from a
page. I want to grab only the data between two specific tags
"<!--StartTag--" and "<!--EndTag--"

Is there any way to do this? The webquery built into excel does not
seem to allow for this kind of specific parsing. Any help would be
appreciated.

thanks,
dave


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

Thanks,

that is precisely what i was looking for!!!

Dave

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

The following function will take a URL, a start string (in your case, pass
in "<!--StartTag--"), and an end string ("<!--EndTag--") and will retun
the HTML source inbetween them. If you want the actual text displayed on
the screen, then you can change InnerHTML to InnerText, but you will have

to
use 2 visible text strings (not HTML comments) as the start and end
arguments.

Public Function gsGetString(rsURL As String, _
rsStartHTML As String, rsEndHTML As String) As String
Dim ie As Object
Dim sHTML As String
Dim lStartPos As Long
Dim lEndPos As Long

Set ie = CreateObject("InternetExplorer.Application")

With ie
.Navigate rsURL
Do Until Not .Busy And .ReadyState = 4
DoEvents
Loop
sHTML = .Document.Body.InnerHTML
End With

ie.Quit
Set ie = Nothing

lStartPos = InStr(1, sHTML, rsStartHTML, vbTextCompare)
If lStartPos Then
lStartPos = lStartPos + Len(rsStartHTML)
lEndPos = InStr(lStartPos, sHTML, rsEndHTML, vbTextCompare)
If lEndPos Then
lEndPos = lEndPos - 1
gsGetString = Mid$(sHTML, lStartPos, lEndPos _
- lStartPos + 1)
End If
End If
End Function

--
Regards,

Jake Marx
www.longhead.com

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


Daveed wrote:
Hi,

I am trying to perform a webquery that grabs specific data from a
page. I want to grab only the data between two specific tags
"<!--StartTag--" and "<!--EndTag--"

Is there any way to do this? The webquery built into excel does not
seem to allow for this kind of specific parsing. Any help would be
appreciated.

thanks,
dave




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
Import New Database Query (Union Query) in Spreadsheet klock Excel Discussion (Misc queries) 2 September 24th 09 01:30 AM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 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 10:00 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"