PDA

View Full Version : Breakapart innerhtml in Excel



jhize
11-30-2006, 11:11 AM
Hi,

I have captured data from a table in IE and have it going to range"a1"


Set mytable = IeApp.document.getElementById("maindetail")
Sheets("sheet1").Activate
Sheets("sheet1").Range("a1").Value = IeApp.document.getElementById("maindetail").innerHTML

I'd like to "parse" this data so that the html tags are removed and each item is placed in its own cell (a1, a2, a3 etc.

Thanks

Charlize
11-30-2006, 12:15 PM
A little bit more info would be welcome. Maybe rest of your code so at least we know what kind of site (or the url) you want to parse to excel. Is the html-page formatted as a table or not ? Is there more than one table on this page. Can we look at div-tags ? Or is there a link on the page itself to parse it to excel ?

How is the info placed in A1 ? Are they seperated by a special character (, or " or something else ?) ?

Charlize

jhize
11-30-2006, 01:26 PM
The url is corporate and I cannot post it. I actually was able to use innertext instead of innerhtml. Now all tags are removed but each item i need in individual cells are seperated by char(10). That should be an easy fix.

Thanks

Norie
11-30-2006, 01:38 PM
If you are going to cross post at least provide a link http://www.ozgrid.com/forum/showthread.php?t=60994.

SamT
12-01-2006, 06:11 AM
jhize,

Sorry, it's still too early for me to try any coding, but. . .
Now this AIN'T code:

As I understand it you have the string
wordChar(10)wordChar(10)wordChar(10)word


Build a loop
i as LoopCounter
While StringInActiveCell <> ""
IF find Char(10) '[means two or more words]
Let l = location first Char(10)
'[Put word(i) in appropriate column]
ActiveCell.Offset(0, i) = StringLeft to l
String = l to StringRight '[take THAT word out of String]
Else Only one word
ActiveCell.Offset(0, i) = String
Endif
Next i
End Loop
'[put start of word list back in activecell]
Range(Offset(0, 1):Offset(0, i)).Copy destination:= ActiveCell
'
'
'


Hoping this brings your Muse,
SamT


Where's my coffee?!?!?!