Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

How To Copy A Dynamic Content of Webtable Into To EXCEL Sheet

This document provides instructions to copy dynamic content from web tables into an Excel sheet using three main steps: 1. It describes how to use objects to recognize and return all tables on a webpage into an object collection. 2. It then loops through each table, rows, and columns to get the cell value and paste it into the Excel sheet. 3. Finally, it saves the Excel file after copying all tables and quits the Excel application.

Uploaded by

Marcus Meyer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

How To Copy A Dynamic Content of Webtable Into To EXCEL Sheet

This document provides instructions to copy dynamic content from web tables into an Excel sheet using three main steps: 1. It describes how to use objects to recognize and return all tables on a webpage into an object collection. 2. It then loops through each table, rows, and columns to get the cell value and paste it into the Excel sheet. 3. Finally, it saves the Excel file after copying all tables and quits the Excel application.

Uploaded by

Marcus Meyer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

How to copy a Dynamic content of webtable into to EXCEL sheet

Note: You can use webelement objects to recognize webtables, if the data is not dynamic

'creating a general description object
Set mypage=browser("name:=.*").page("title:=.*")

'Creating a general description obect for table

Set table_desc=Description.Create()
table_desc("html tag").value="TABLE" 'for all tables
'table_desc("column names").value="Hello.*" for all tables with column names starting with hello


'All tables matching above will be returned into all_tables()
Set all_tables=mypage.childobjects(table_desc)

table_count=cint(all_tables.count) 'Get total count of tables

msgbox "we have "& table_count &" tables in the open browser"


Set oXl=createobject("Excel.application")
'oxl.Workbooks.add "C:\webtable.xlsx"
oxl.Workbooks.Open "C:\webtable.xlsx"
Set sheet=oxl.ActiveWorkbook.Worksheets("sheet1")

xl_row=1 'set excel row

For icount = 0 To table_count-1 Step 1
sheet.cells(xl_row, 1).value="Table No:"&icount+1 ' Insert a header before a table

For irowcount = 1 To all_tables(icount).rowcount 'for every row in each webtable
For icolcount= 1 To all_tables(icount).columncount(irowcount) 'for every column in each web table
get cellvalue
cell_value=all_tables(icount).getcelldata(irowcount, icolcount)
sheet.cells(irowcount+xl_row, icolcount).value=cell_value
'msgbox cellvalue

Next
Next
xl_row=irowcount+xl_row+1 'increase the row count for next table
Next


oxl.ActiveWorkbook.save
oxl.ActiveWorkbook.Close
oxl.application.Quit

You might also like