rojo
02-26-2014, 04:22 AM
Hi All,
First time to the forum and the first post ever I think! Trying to learn VBA, HTML and hopefully databases but so far very much a beginner.
I'm hoping someone can help me with this, normally I would search the web for a solution but this one is hard for me!
I have a VBA program that pulls a table form a website and pastes this on a sheet, I have it working fine on my home pc but cant get it to work on my work PC. I'm pretty sure its down to Internet Explorer as I am using IE11 and work is IE8.
Once logged into the website I pull a table using its classname, there is no ID or Tag name, I understand IE8 doesn't support GetElementsByClassName so have tried using querySelector but the website isn't using CSS3 so that doesn't work either.
The nesrest I have got it by using getElementById but this gets the form element and then I don't know how to get the div element from the form element..?
I really hope this makes sence as I am not 100% sure what I am talking about.
Working code for IE9+
'get the table based on the table’s class
Set ieDoc = ieApp.document
Set ieTable = ieDoc.GetElementsByClassName("log")(0)
'copy the tables html to the clipboard and paste to the sheet
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "<html>" & ieTable.outerHTML & "</html>"
clip.PutInClipboard
and I can use this to get the HTMLFormElement
Set ietable = ieDoc.getElementById("aspnetForm")
start of the table...
<div class="log" reportentryid="11719" entrytype="Log">
<table class="grid scrollable">
Be grateful if someone can help, please let me know if I need to explain or post more...?
Cheers
First time to the forum and the first post ever I think! Trying to learn VBA, HTML and hopefully databases but so far very much a beginner.
I'm hoping someone can help me with this, normally I would search the web for a solution but this one is hard for me!
I have a VBA program that pulls a table form a website and pastes this on a sheet, I have it working fine on my home pc but cant get it to work on my work PC. I'm pretty sure its down to Internet Explorer as I am using IE11 and work is IE8.
Once logged into the website I pull a table using its classname, there is no ID or Tag name, I understand IE8 doesn't support GetElementsByClassName so have tried using querySelector but the website isn't using CSS3 so that doesn't work either.
The nesrest I have got it by using getElementById but this gets the form element and then I don't know how to get the div element from the form element..?
I really hope this makes sence as I am not 100% sure what I am talking about.
Working code for IE9+
'get the table based on the table’s class
Set ieDoc = ieApp.document
Set ieTable = ieDoc.GetElementsByClassName("log")(0)
'copy the tables html to the clipboard and paste to the sheet
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "<html>" & ieTable.outerHTML & "</html>"
clip.PutInClipboard
and I can use this to get the HTMLFormElement
Set ietable = ieDoc.getElementById("aspnetForm")
start of the table...
<div class="log" reportentryid="11719" entrytype="Log">
<table class="grid scrollable">
Be grateful if someone can help, please let me know if I need to explain or post more...?
Cheers