page select in multipage web site
Here is some debug code you may need. The row where I put ID in column C may
need to be commented out because not all webpages support the property ID.
Look for the word Next in column D to help find the navigation object.
Sub Macro3()
'
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "http://www.google.com/"
Search = "search?hl=en&q=joel&aq=f&oq=&aqi=g10"
'get web page
IE.Navigate2 URL & Search
Do While IE.readyState < 4 And IE.busy = True
DoEvents
Loop
'put you code here
RowCount = 1
For Each itm In IE.document.all
Range("A" & RowCount) = itm.tagname
Range("B" & RowCount) = itm.classname
Range("C" & RowCount) = itm.ID
Range("D" & RowCount) = Left(itm.innertext, 1024)
RowCount = RowCount + 1
Next itm
Set Nextobj = IE.document.getElementByID("nav")
If Not Nextobj Is Nothing Then
Set NextPage = Nextobj.Cells(Nextobj.Cells.Length - 1)
Search = NextPage.FirstChild.nameprop
End If
End Sub
"Stefi" wrote:
Thanks to both of you, r and Joel, I'm going to follow the ways you showed
me. It's interesting that there is no simpler way for handling such an
everyday case!
Stefi
€˛Joel€¯ ezt Ć*rta:
I did a search on goolge to get a multi-page results and got this code. I
won't guarentee it will work in your case but it will give you an example. I
searched for the ID=nav to get the navigation object and then created a new
URL. I found that hoovering over the NEXT button showed the same results as
the NAV property.
Sub Macro3()
'
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "http://www.google.com/"
Search = "search?hl=en&q=joel&aq=f&oq=&aqi=g10"
Do
'get web page
IE.Navigate2 URL & Search
Do While IE.readyState < 4 And IE.busy = True
DoEvents
Loop
'put you code here
Set Nextobj = IE.document.getElementByID("nav")
If Not Nextobj Is Nothing Then
Set NextPage = Nextobj.Cells(Nextobj.Cells.Length - 1)
Search = NextPage.FirstChild.nameprop
End If
Loop While Not Nextobj Is Nothing
End Sub
"Stefi" wrote:
Hi All,
I have a multipage web site, where
Set coursetables = IE.document.getElementsByTagname("table")
and after that
?coursetables.Item(16).Rows(0).Cells(0).innertext
returns
Page 1 of 2
Previous Page | Next Page
On the web page clicking manually on Next Page bring up the next page.
How can I find the object that can be clicked on in VBA (like clicking on a
button is done via myButton.click) to bring up the next page?
Thanks,
Stefi
|