Internet Automation Highlighting Text on Webpage

gypsyjoe11

Registered User.
Local time
Today, 06:57
Joined
Feb 19, 2010
Messages
46
Hi Everyone,

I don't have any folder/install permissions at work and we're forced to use internet explorer 6.

I've automated a bunch of tasks for the office staff where they have to log into the HR/Training web app. After they login they can run my program to do a variety of mundane tasks. It handles the Javascript menu trees and pop-up boxes.

Currently they have to print out a couple of tables from different places and then manually highlight certain lines on them. Then the hardcopies are put into a package for approval by different people. The tables are not organized and it takes awhile to do it by hand.

I'm trying to figure out a way to change the background color or certain table rows and then print out the webpage.

I've tried:

Code:
Dim myTable As HTMLTable
Set myTable = mainFrame.getElementsByTagName("TABLE").Item(6)
 
debug.Print myTable.rows(5).getElementsByTagName("TD")(0).outerhtml
 
<TD class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>


From the above it looks like the formating info for the row I want to highlight is in the first row cell (TD).

I've tried the below to change it without success in the immediate window

Code:
myTable.rows(5).getElementsByTagName("TD")(0).value = "<TD style=""background-color:yellow;"" class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>"
'Gives error object doesn't support this property or method
 
myTable.rows(5).getElementsByTagName("TD")(0).outerhtml.value = "<TD style=""background-color:yellow;"" class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>"
'gives error object required
 
myTable.rows(5).getElementsByTagName("TD")(0).outerhtml = "<TD style=""background-color:yellow;"" class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>"
'gives error 600 - application defined error

Any ideas? Also wondering how to print out the webpage?

thanks,

Joe
 
Interesting issue Joe...

I'm not really understanding what you're trying to do. You're getting data from the webpage then? You're copying table data from a webpage and you want to highlight certain rows automatically?

I'm sorry but I'm trying to get at what you need....If you're trying to manipulate actual tables from an HTML page though, have you considered using MS query in Excel? You can automate the download of those by writing macros...and at that point you could add just a couple more lines to loop the file and color as needed.
 
Hi Joe again,

you really like punishing yourself with this automation stuff. I hope I can help.

I don't have any folder/install permissions at work and we're forced to use internet explorer 6.
Very annoying. We just moved to IE7. By the way all your ActiveX stuff will break when IT moves to IE7. You will have top open your forms, and sometimes even add the activeX IE control again, and then redistribute it. I did.

First you can only work on the DOM (HTML Document Object Model) when IE fires the DocumentComplete event for your HTML page. Before then your will get errors of the changes will not happen.

Second I am not sure if you can change an element like a table. I thought you could only make changes to the main document. I am worried that even if you change it that you will not see the changes.

So first step is to change it. Second is to see the changes in IE.

Code:
Dim myTable As HTMLTable
Set myTable = mainFrame.getElementsByTagName("TABLE").Item(6)
 
debug.Print myTable.rows(5).getElementsByTagName("TD")(0).outerhtml
 
<TD class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>

Ok so you are good so far you can get the TD you want. But you talk about ROWS - this is TR and a cell is a TD. Title cells are TH.

Do you really want the TD????

Code:
myTable.rows(5).getElementsByTagName("TD")(0).value = "<TD style=""background-color:yellow;"" class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>"
'Gives error object doesn't support this property or method
 
myTable.rows(5).getElementsByTagName("TD")(0).outerhtml.value = "<TD style=""background-color:yellow;"" class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>"
'gives error object required
 
myTable.rows(5).getElementsByTagName("TD")(0).outerhtml = "<TD style=""background-color:yellow;"" class=PSLEVEL1GRIDODDROW align=left height=14>000232 </TD>"
'gives error 600 - application defined error
I dont think you are going about this the right way. You need to look at your html and first get the html changed how you like it. I am not great with HTML but I would suggest that you amend the style of the TR/TD element only. By this I mean copy your HTML into a notpad document and name it test.html - then manually make the changes as you like. Then open the doc in IE to see if it works. Then we can work on getting what you have managed to do.

something like this - you will not be able to cut and copy but I hope you can work it out.

Code:
Dim joeTR As HTMLTableRow

***here set joeTR to the row you want to change the color of***

joeTR.Style.backgroundColor = "yellow"
Now after doing this if you do not see the color then get the outerhtml of this TR element to see if it has been changed at all.
 
If you cut the HTML for the Table out and put it in a text document with a HTML ending. Then make sure IE will show the table properly. Then upload it here, maybe I could look at it too.
 

Users who are viewing this thread

Back
Top Bottom