How to fetch the table from ASP web site and save in Excel

  • their is search tool web site (.aspx), which will give the list of data in a table format (Rows & Columns) upon clicking submit button. i want to fetch the second column data from the table and have to save that in a excel. I have already wrote the code for opening the web site and clicking submit botton. I have attached the source code of the web site in this thread. Can anyone give me the sample code to fetch the second colume in the 12th table of the web site.


    I have to add the sample code which you are going to provide in below code,

  • Re: How to fetch the table from ASP web site and save in Excel


    Try something like this.


    This is untested but should do what you want based on your description.

  • Re: How to fetch the table from ASP web site and save in Excel


    Hi,


    I tried the code you provided above, but i am getting the "Runtime error 91: Object variable or With block variable not set[FONT=arial]" for the below line.


    Can you help me with this.

  • Re: How to fetch the table from ASP web site and save in Excel


    It may be that it is not really the 12th table you are after. Try changing the item number in

    Code
    Set IeTbl = objIE.Document.getelementsbytagname("Table").Item(12)


    to lower numbers and see if that helps


    Edit: I just tried the code with a random web page and got the same error until I lowered the item number. Verify the table number you are after.

  • Re: How to fetch the table from ASP web site and save in Excel


    I tried all the number back and front. still i am getting the same error.


    "Runtime error 91: Object variable or With block variable not set[FONT=arial]" for the below line

    Set IeTbl = objIE.Document.getelementsbytagname("Table").Item(12)


    I am badly need this for my project. Instead of copying the cells, if the whole table is copied to excel then it is fine for me.


    Could you please help me how to copy the table from ASP web site to excel?


    Thanks in advance.

  • Re: How to fetch the table from ASP web site and save in Excel


    I am not sure what further advice I can give you without being able to access the web page. The code that I posted is pretty standard for grabbing tables. You could loop through all of the TD tags and write those to cells and then pick out what you need possibly.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!