View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Extracting specific items from large IE table

The web query method will work because you can enter the password into the
query IE explorer and then browse to any directory you want. The query won't
end until you select a table and press the import button on the query window.

"expect_ed" wrote:

Thanks for the quick reply, joel,

Your first method is unworkable for me because I cannot get the correct page
into the Web Query box. When I click on the link a new browser window opens
with an error message. If I paste the URL for the resulting page - the one
that is the same for all pages - I get the login screen for the Web app. If
I try to right click the link to force it to open in the same window I do not
get that as an option.

I imagine there must be a VBA instruction that will direct XL to the open IE
window. Perhaps if I had that I could try your second method. Otherwise I
have the same problem that copying the URL of the page to direct XL to open
does not get me to the correct page so I cannot even get started with your
idea.

Thanks for the help.
ed

"joel" wrote:

I usually start with a few different methods

1) You can try to import the table using Data - Import Query - New Web
query. Record a macro while doing this a try to select the table you want.
The recorded macro will contain the table number that you can use in your vba
code. the table number is off by one because the query numbering starts at 1
and the VBA array starts at zero.

Set Tables = IE.document.Table("Table")
set mytable = table(12) 'really table 13

2) I dump the webpage to the worksheet using this code

RowCount = 1
for each itm in IE.document.all
Range("A" & RowCount) = itm.tagname
Range("B" & RowCount) = itm.classname
Range("A" & RowCount) = left(itm.innertext,1024)
RowCount = RowCount + 1
next itm

This line will get the tags
Set Form = IE.document.getElementsByTagname("Table")
This line will get the items that have id="abc" in the html
On some webpages the classname is the id.
Set zip5 = IE.document.getElementById("zip5")

3) Once you get the table to extract use rows then cells

RowCount = 1
For each myrow in Table.Rows
ColCount = 1
For each cell in myrow.cells
cells(RowCount,ColCount) = cell.innertext
ColCount = ColCount + 1
next cell
RowCount = Rowcount + 1
next MyRow



"expect_ed" wrote:

Trying to pull out specific items from a large IE table (500 rows, 1-4 cols).
Very limited knowledge of HTML is making it harder. Several questions:

Examples I have seen here always call the URL. The page I want to read
seems to come from a 'Post' Method and the URL is the same regardless of
which of thousands of documents you want. I can get to the front page of the
doc ok, but then must press a link which ends up with a URL like:
http://server.comp.com:8080/appl/requests.do
Is it possible to direct XL to the IE window if I am already on the page I
want?

Next problem is I am not sure I understand tag names well enough to know
what to put in the xxx's in the instruction:
Set Table = IE.document.getElementsByTagname("xxx")

I would like to go to row 483 of the table and extract the last column. The
HTML of the page looks something like this for each row/column:

<tr style='mso-yfti-irow:483'
<td {formatting info}
<p class=MsoNormal<span style='{more formatting
info}CellContent<o:p</o:p</span</p
</td
...td - /td repeats for number of columns on that page

What is confusing me is that first style='. Is the 'mso-yfti-irow:483' a
tag name I can use to get to an exact row of the table or is the only way to
For-Next through all the rows until I get to the one I want to extract?

All help greatly appreciated.
ed