+ Reply to Thread
Results 1 to 5 of 5

Copy data from HTML table to Excel

  1. #1
    Registered User
    Join Date
    06-27-2014
    Location
    Comillas, Spain
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Post Copy data from HTML table to Excel

    Hi,

    I am trying to execute some code that will open a website, submit a form and retrieve some data from that same website.

    So far I have been able to accomplish two of the three things mentioned above, but I seem stuck now.

    Basically what my code does so far is: opens IE, waits for it to load, copies a value from a cell to a website form and submits the form.

    So far so good, problem is I don't know how to copy the value I want and paste it back to a cell in Excel.

    Can anybody help me?

    The website I am testing this on is: "http://www.abc.es/loteria-de-navidad/buscardecimo.asp"

    What I would like to do is retrieve the 20 euro value with the red background when the value submitted to the web form is: "11750"

    Here's what i got this far:

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    11-28-2013
    Location
    Lima Peru
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Copy data from HTML table to Excel

    Hola javi.xls
    Type 11750 into the A1 cell of your current worksheet and then run the following code. In order for this code to work, you will need to reference the following libraries:
    -Microsoft Internet Controls and
    -Microsoft HTML Object Library

    Please Login or Register  to view this content.
    Last edited by EduardoHiguchi; 01-13-2016 at 07:16 PM.

  3. #3
    Registered User
    Join Date
    11-28-2013
    Location
    Lima Peru
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Copy data from HTML table to Excel

    If you find any problem with the code, please do not hesitate to let me know

  4. #4
    Registered User
    Join Date
    06-27-2014
    Location
    Comillas, Spain
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Copy data from HTML table to Excel

    Quote Originally Posted by Lalo1977 View Post
    If you find any problem with the code, please do not hesitate to let me know
    Lalo1977,

    Your solution runs smoothly! It's brilliant!

    Since I am completely new to anything related to javascript and HTML, could you explain how you came up with the website you are accessing? How can I reproduce this in other websites with HTML tables?

    I have tried your solution in the website I provided and it does not seem to detect the element in the table, the for each...next loop does not detect the element I want, is there a reason to this?

    Also, I am trying to create a more sophisticated solution which needs to loop through the same page several times, would you know how to activate a window/tab that is already open in IE instead of closing it and opening it again?

    Thanks A LOT for your help! You are the best!

  5. #5
    Registered User
    Join Date
    11-28-2013
    Location
    Lima Peru
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Copy data from HTML table to Excel

    Hello javi-xls,
    I am glad to know that the code worked.
    The website that you provided (http://www.abc.es/loteria-de-navidad/buscardecimo.asp) uses iframe tags. "iframes" are HTML documents inside another HTML document. In this case the iframe with source "http://loteria.abc.es/fcgi-bin/premio.pl?numero=&importe=" is inside the main document.
    I realized this by using Chrome´s HTML element inspector. You can activate this inspector by first going to the website address with Chrome, then pressing CTRL+Shift+C, then selecting the element with the mouse pointer and finally clicking at it. After clicking the element you will see the element position in the HTML source code. By analysing this HTML code you will be that the able to see that the span element you re looking for is inside a td element which is inside a table element and this element is inside anothet, and so on.. and all these elements are inside an "iframe" tag that has an "src" attribute, and the value of this src attribute is = http://loteria.abc.es/fcgi-bin/premi...mero=&importe= which is the URL of another page. By filling the numero= and the importe= parameters your browser makes a request to a web server that returns a page with the information submitted by the parameters.
    Could you please mark your thread as 'Solved' to keep the moderators happy You can do that in thread tools, the button is on the right, just above the first post. Have a nice day!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA to Import HTML Table Locally Stored HTML file to excel
    By ermengard in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-09-2015, 10:48 AM
  2. Having a problem getting html table data
    By zacherypoche in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2014, 11:54 PM
  3. Copy data from html into excel using vba code
    By flaviu123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2014, 09:32 AM
  4. pull data to HTML from excel table
    By yrndtn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2010, 04:11 PM
  5. Copy and Paste Table into String in HTML format
    By Jay59 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2008, 12:32 PM
  6. How to copy a set of data from an Excel table and display it in html?
    By sapphire in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2008, 08:27 PM
  7. pasting data from HTML table
    By bmccall17 in forum Excel General
    Replies: 3
    Last Post: 01-17-2007, 05:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1