Results 1 to 6 of 6

Thread: [RESOLVED] Can't access any objects on a web page? - no frame or iframe

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    19

    Resolved [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

  2. #2
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    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

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    19

    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

  5. #5
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    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
    Last edited by His Nibbs; Feb 6th, 2012 at 11:14 AM.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    19

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width