Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Get a value from a table in an HTML document

LOL
Ive been staring at the MSDN site all night now, I can't get my head around
it all. But I'll keep trying.

Thanks Dick
Terry V

"Dick Kusleika" wrote in message
...
Terry

"Terry V" wrote in message
...
Thank you Dick for your replies.
---- If ieDoc.URL Like "http:\\www.myweb.com\*"
This is more of what Im looking for.
If the URL of the webpage is like http://www.domain.com/docname*


So you can find the right HTMLDocument, now you just need to find the

right
information on it. Does that sound right?


within that html document, what does the 564 represent?


An HTMLDocument has a number of elements on it. Elements are tables,

links,
divs, etc. I would give you a more concrete definition, but I don't

really
know it that well. ieDoc.all returns a collection of all the elements and
we loop through them. If you know which element you need, you can go
directly to it. Say there's 1000 elements on your document and the table
you need is the 564th. You can go right to that element because you know
it's the 564th element.

In the example I gave before, there are 319 elements. Here's a sample

306 HTMLParaElement
307 HTMLLabelElement
308 HTMLInputElement
309 HTMLBRElement
310 HTMLParaElement
311 HTMLLabelElement
312 HTMLBRElement
313 HTMLTextAreaElement
314 HTMLDivElement
315 HTMLInputElement
316 HTMLInputElement
317 HTMLDivElement
318 HTMLScriptElement
319 HTMLImg

I wanted to present that method to you, but honestly I would almost never
use it. Hardcoding a number like that is scary. If one little thing
changes and you are off by one number, it's broke, and you may as well be
off by 10,000.

What Im attempting to do is : at work, I want to be able to keep track

of
clients that call each day, then place them into a worksheet. So that

when
I need to do a review of all clients that called back with a repeat
incident, I can track it. When they call in, thier info is placed into

a
dynamic html document (maybe php; can't remember) where the fields are

all
the same in the generated table and the values are placed in the same
column/cell as the previous or next client info.

So, Im trying to get the Date and email address to be placed into my

excel
sheet to prevent me from copy/paste for several hrs at the end of each
period.... then having to manually / visually match the names.

Right now, I have to lookup every client for each day's work to see if

they
called back. however, if I can keep track of each person that called, I

can
automate a lookup for each name in the list. Saving myself approx 20 hr
work (unpaid) at the end of each month.


When I'm trying to work with HTML from VBA, here's what I do. I go to
http://msdn.microsoft.com/library/default.asp and navigate like this: Web
Development HTML and Dynamic HTML SDK Documentation Reference
Objects. I usually start with the Document object and I search around for

a
property or collection that looks like what I need. I just don't know

this
object model well enough to go directly to what I need so it's a lot of
searching for something that looks right. You can go there and search
around for something better based on what you know about the HTMLDocument
you have. I'm telling you this because I don't want you to think that my
way is definitive. It's just the only way I've figured out so far.

With your Like operator, you can find the right document and set that to
ieDoc. Now you need to find the right table. You need to figure our what
is unique about that table. Is it the only table in the document? If so,
just loop through the elements in ieDoc.all until you get one whose

TypeName
is HTMLTable, and you know you will be there. If there's more than one
table in the Document, but you know which number it is, say the 10th

table,
you could loop through all the elements and keep count of the HTMLTable
objects you encounter. When you get to number 10, stop and use
Cells(x).InnerText to get the values you need.

You saw from my first example that I checked the InnerText of Cells(0)

(the
first cell) and that was an example to use if the text in the first cell

is
consistent and you can use that to identify that you're in the right

table.

Let's say that the first cell will be a date, but that the date can

change.
If it's also true that no other tables will have a date in their first

cell,
you could use this information to identify the correct table. For example:

For Each ieTbl in ieDoc.all
If TypeName(ieTbl) = "HTMLTable" Then
If IsDate(ieTbl.Cells(0).Innertext) Then
Sheet1.Cells(1,1).Value = ieTbl.Cells(8).Innertext
End If
End If
Exit For
Next ieTbl

I know I'm not giving you the concrete answers you probably want, but it's
all I've got. Once you can determine what's unique about that table such
that you can identify it, the rest should be easy. If you can tell me
what's unique, but you still need help with the code, post back. If you
can't tell me what's unique, tell me why you can't or think you can't. I
assume an example document is not available for me to look at, but if I'm
wrong, tell me that too.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown list in HTML document AmyD Excel Discussion (Misc queries) 0 October 27th 09 07:27 PM
Import HTML Table JimJx Setting up and Configuration of Excel 0 July 23rd 07 01:44 PM
Displaying select cells in HTML document Alex Excel Discussion (Misc queries) 0 June 8th 07 07:59 PM
I'd like to use Excel to make changes to an HTML document... Jola Excel Discussion (Misc queries) 2 March 7th 06 02:29 PM
How to open a Word or HTML document using VBA code in Excel TBA[_2_] Excel Programming 1 January 21st 04 03:19 AM


All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"