Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Excel Web Query does not return hyperlink

With Office Professional Excel 2003, when I use a web query, some sites
return hyperlinks while others do not. I have set the option "Full HTML
formatting" on.

Examples: for http://www.yahoo.com, the hyperlinks show up in the worksheet,
but for
http://www.craigslist.com, they do not show up as hyperlinks.

I am not familiar enough with HTML to understand the differences in the web
sites.

Is there any workaround for this?

thanks, Mike
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Excel Web Query does not return hyperlink

It all depends on the tools and how the webpage was created. You can always
write a macro like the one below to get the links

Sub Getchemicals2()

Found = False
For Each sht In Sheets
If sht.Name = "Chemicals" Then
Found = True
Exit For
End If
Next sht
If Found = False Then
Set ChemicalSht = Sheets.Add(after:=Sheets(Sheets.Count))
ChemicalSht.Name = "Chemicals"
Else
Set ChemicalSht = Sheets("Chemicals")
ChemicalSht.Cells.ClearContents
End If


Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True

URLFolder = _
"http://www.ilo.org/public/english/protection/safework/cis/products/icsc/dtasht/"
ChemicalRowCount = 1
For Letters = 0 To 25
AlphaLetter = Chr(Asc("a") + Letters)

URL = URLFolder & AlphaLetter & "_index.htm"

'get web page
ie.Navigate2 URL
Do While ie.readyState < 4
DoEvents
Loop

Do While ie.busy = True
DoEvents
Loop

H2Found = False
For Each itm In ie.Document.all
If H2Found = False Then
If itm.tagname = "H2" Then
H2Found = True
End If
Else

If itm.tagname = "A" Then
If itm.innertext = "" Then Exit For

'chemical name
ChemicalSht.Range("A" & ChemicalRowCount) = itm.innertext
'webpage
ChemicalSht.Range("B" & ChemicalRowCount) = itm.href

ChemicalRowCount = ChemicalRowCount + 1
End If
End If
Next itm

Next Letters


End Sub

"MikeA" wrote:

With Office Professional Excel 2003, when I use a web query, some sites
return hyperlinks while others do not. I have set the option "Full HTML
formatting" on.

Examples: for http://www.yahoo.com, the hyperlinks show up in the worksheet,
but for
http://www.craigslist.com, they do not show up as hyperlinks.

I am not familiar enough with HTML to understand the differences in the web
sites.

Is there any workaround for this?

thanks, Mike

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Excel Web Query does not return hyperlink



"Joel" wrote:

It all depends on the tools and how the webpage was created. You can always
write a macro like the one below to get the links

Sub Getchemicals2()

Found = False
For Each sht In Sheets
If sht.Name = "Chemicals" Then
Found = True
Exit For
End If
Next sht
If Found = False Then
Set ChemicalSht = Sheets.Add(after:=Sheets(Sheets.Count))
ChemicalSht.Name = "Chemicals"
Else
Set ChemicalSht = Sheets("Chemicals")
ChemicalSht.Cells.ClearContents
End If


Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True

URLFolder = _
"http://www.ilo.org/public/english/protection/safework/cis/products/icsc/dtasht/"
ChemicalRowCount = 1
For Letters = 0 To 25
AlphaLetter = Chr(Asc("a") + Letters)

URL = URLFolder & AlphaLetter & "_index.htm"

'get web page
ie.Navigate2 URL
Do While ie.readyState < 4
DoEvents
Loop

Do While ie.busy = True
DoEvents
Loop

H2Found = False
For Each itm In ie.Document.all
If H2Found = False Then
If itm.tagname = "H2" Then
H2Found = True
End If
Else

If itm.tagname = "A" Then
If itm.innertext = "" Then Exit For

'chemical name
ChemicalSht.Range("A" & ChemicalRowCount) = itm.innertext
'webpage
ChemicalSht.Range("B" & ChemicalRowCount) = itm.href

ChemicalRowCount = ChemicalRowCount + 1
End If
End If
Next itm

Next Letters


End Sub


Thanks for the comprehensive example. It really helps to get a complete
working example vice a few of the key lines. Anyway, I did get something
working, but is seems like a difficult solution to maintain/reapply. A few
questions:

Is there an easy way to find the tags used on the web page; I examined the
source, but due to poor formatting (no logical text wrap) it is easy to get
lost/confused. Is there a way to search for (for example) the second table.

Do you know what is missing from the page I am using that prevents the web
query from getting the links?

thanks again, Mike
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Excel Web Query does not return hyperlink

This website has been down since the eveniong of the 23rd. it finally came
back up this morning.

I first look at the webpage using the Internet Explorer at use the menu
option VIEW - SOURCE which shows the source code in Notepad. The TAG items
start with a forward slash and ends with a 2nd forward slash ((may include
tag name

/abc ................ /

or

/abc ................ abc/

Tags can be nested and the slashes are always in pairs (an opening and
closing tag)


To get all the TAG info I usally use the code for SHEET1 below to get the
information.

You can get a trag name like in my example below for SHEET2

set MyTags = IE.document.getelementsbytagname("*")

or

set MyTags = IE.document.getelementsbytagname("abc")

You can also get classes which are shown in the source code as

name="top"</a<div id="msviMasthead"<table cellpadding="0"

The class name starts with id=

Which in this case is msviMasthead

Use this code to get the class

Set Class = IE.document.getElementById("msviMasthead")

See my code for SHEET3 below.



Sub test()

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://www.nissanusa.com/apps/dealerlocator"
Request = "?zipCode=07508&tool=Home.Locator"

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState < 4
DoEvents
Loop

With Sheets("Sheet1")
RowCount1 = 1
For Each itm In IE.document.all
.Range("A" & RowCount1) = itm.tagname
.Range("B" & RowCount1) = itm.ClassName
.Range("C" & RowCount1) = Left(itm.innertext, 1024)

RowCount1 = RowCount1 + 1
Next itm
End With

With Sheets("Sheet2")
RowCount2 = 1
For Each itm In IE.document.getelementsbytagname("*")
.Range("A" & RowCount2) = itm.tagname
.Range("B" & RowCount2) = itm.ClassName
.Range("C" & RowCount2) = Left(itm.innertext, 1024)

RowCount2 = RowCount2 + 1
Next itm
End With

With Sheets("Sheet3")
RowCount3 = 1
For RowCount = 1 To RowCount1 - 1
ClassName = Sheets("Sheet1").Range("B" & RowCount)
If ClassName < "" Then
Set Class = IE.document.getElementById(ClassName)
If Not Class Is Nothing Then
.Range("A" & RowCount3) = Class.tagname
.Range("B" & RowCount3) = Class.ClassName
.Range("C" & RowCount3) = Left(Class.innertext, 1024)
RowCount3 = RowCount3 + 1
End If
End If
Next RowCount
End With

End Sub


"MikeA" wrote:



"Joel" wrote:

It all depends on the tools and how the webpage was created. You can always
write a macro like the one below to get the links

Sub Getchemicals2()

Found = False
For Each sht In Sheets
If sht.Name = "Chemicals" Then
Found = True
Exit For
End If
Next sht
If Found = False Then
Set ChemicalSht = Sheets.Add(after:=Sheets(Sheets.Count))
ChemicalSht.Name = "Chemicals"
Else
Set ChemicalSht = Sheets("Chemicals")
ChemicalSht.Cells.ClearContents
End If


Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True

URLFolder = _
"http://www.ilo.org/public/english/protection/safework/cis/products/icsc/dtasht/"
ChemicalRowCount = 1
For Letters = 0 To 25
AlphaLetter = Chr(Asc("a") + Letters)

URL = URLFolder & AlphaLetter & "_index.htm"

'get web page
ie.Navigate2 URL
Do While ie.readyState < 4
DoEvents
Loop

Do While ie.busy = True
DoEvents
Loop

H2Found = False
For Each itm In ie.Document.all
If H2Found = False Then
If itm.tagname = "H2" Then
H2Found = True
End If
Else

If itm.tagname = "A" Then
If itm.innertext = "" Then Exit For

'chemical name
ChemicalSht.Range("A" & ChemicalRowCount) = itm.innertext
'webpage
ChemicalSht.Range("B" & ChemicalRowCount) = itm.href

ChemicalRowCount = ChemicalRowCount + 1
End If
End If
Next itm

Next Letters


End Sub


Thanks for the comprehensive example. It really helps to get a complete
working example vice a few of the key lines. Anyway, I did get something
working, but is seems like a difficult solution to maintain/reapply. A few
questions:

Is there an easy way to find the tags used on the web page; I examined the
source, but due to poor formatting (no logical text wrap) it is easy to get
lost/confused. Is there a way to search for (for example) the second table.

Do you know what is missing from the page I am using that prevents the web
query from getting the links?

thanks again, Mike

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
Hyperlink to web does not return to original Excel worksheet g. spence Excel Discussion (Misc queries) 1 November 23rd 07 05:04 PM
why dose excel return invalid web query Barry Excel Discussion (Misc queries) 0 February 25th 06 10:07 PM
How do I set excel to open a hyperlink with the enter/return key? anne New Users to Excel 1 December 27th 05 11:29 PM
Intra-workbook hyperlink: macro/function to return to hyperlink ce marika1981 Excel Discussion (Misc queries) 3 May 6th 05 05:47 AM
Excel - Formula Query: Search for and Return Value Sue Excel Worksheet Functions 3 December 7th 04 12:35 AM


All times are GMT +1. The time now is 01:58 AM.

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"