[RESOLVED] Can't access any objects on a web page? - no frame or iframe
The code below is an entire macro. I am trying to click the first item in the catalog page that loads, to go to that item page. But I can't access any classname, tagname, etc., so I can't click the item. Vba doesn't acknowledge any objects at all exist in the catalog on the web page.
I looked at the source code and searched for frame and iframe. Neither of those terms were found. I think some parts of the page are made of content that comes from other web pages. Here is an example of something I found in the source code-
<!-- Inserted from document templates/Top_Nav.html END-->
Code:
Set ieApp = CreateObject("InternetExplorer.Application")
ieApp.Visible = True
ieApp.navigate "http://www.memorymiser.com/cgi/commerce.cgi?search=action&category=1040"
While ieApp.Busy Or ieApp.readyState <> 4: DoEvents: Wend
Dim appdoc As Object
Set appdoc = ieApp.document
Dim obj As Object
For Each obj In appdoc.all
If obj.tagName = "td" Then
'If obj.tagName = "table" Then
'If obj.tagName = "img" Then
'If obj.tagName = "a" Then
msgbox "found one"
End If
Next obj
Re: Can't access any objects on a web page? - no frame or iframe
Do it by table index then.
Code:
IE.document.getElementsByTagName("TABLE")(11).Rows(1).Cells(0).Children(0).Click
Re: Can't access any objects on a web page? - no frame or iframe
i do not get the page you are talking about, maybe i need to be logged in first?
Re: Can't access any objects on a web page? - no frame or iframe
I don't think I am logged in but it is possible. The site doesn't show anything that says if I am logged in or not.
Thanks for that way of writing the code, it is working great for the most part! I have run into 1 big problem- The last line of the macro below should click the image that says "Secure Checkout". It doesn't result in an error, but the website doesn't move forward to the next page. I can see in the msgbox that it is the right object to click.
Code:
Sub memorymiser()
Set ieApp = CreateObject("InternetExplorer.Application")
ieApp.Visible = True
ieApp.navigate "http://www.memorymiser.com/cgi/commerce.cgi?search=action&category=1040"
While ieApp.Busy Or ieApp.readyState <> 4: DoEvents: Wend
Dim appdoc As Object
Set appdoc = ieApp.document
appdoc.getElementsByTagName("TABLE")(11).Rows(1).Cells(0).Children(0).Click
While ieApp.Busy Or ieApp.readyState <> 4: DoEvents: Wend
appdoc.getElementsByTagName("table")(12).Rows(5).Cells(0).Children(2).Click
While ieApp.Busy Or ieApp.readyState <> 4: DoEvents: Wend
msgbox appdoc.getElementsByTagName("table")(13).Rows(0).Cells(0).Children(0).Children(1).innerHTML
'not working
appdoc.getElementsByTagName("table")(13).Rows(0).Cells(0).Children(0).Children(1).Click
end sub
Re: Can't access any objects on a web page? - no frame or iframe
I wouldn't do it in one line in real life; that was just a quick and dirty way to show you the basics. Also, it's best to use the HTML Object Library, rather than late binding with the Object data type.
For the 'Secure Checkout' try:
Code:
ieApp.document.forms("pdgsecurecheckout").Children(1).Children(0).Click
Re: Can't access any objects on a web page? - no frame or iframe
Thanks, it worked! I didn't know you could use .children for this.