vba - Pulling Bits of info from a bunch of printer status pages into an excel document -
i have bunch of printer status pages pull 3 pieces of dynamic information , place excel spreadsheet via vba. code below, page testing pulls nothing happens after that. pretty new vba , trying work through use little stuck.
sub useclassnames() dim element ihtmlelement dim elements ihtmlelementcollection dim ie object dim html htmldocument 'open internet explorer in memory, , go website' set ie = createobject("internetexplorer.application") ie.visible = true ie.navigate "http://theurl.com" 'wait until ie has loaded web page' while ie.readystate <> readystate_complete application.statusbar = "loading web page .." doevents loop set html = ie.document set elements = html.getelementsbyclassname("results") dim count long dim eorw long count = 0 each element in elements if element.classname = "result" erow = sheet1.cells(rows.count, 1).end(x1up).offset(1, 0).row cells(erow, 1) = html.getelementsbyclassname("statusbox") cells(erow, 2) = html.getelementsbytagname("img")(count).innertxt cells(erow, 3) = html.getelementsbyclassname("status_table")(count).inntertext count = count + 1 end if next element range("a2:c100").select columns("a:a").entirecolumn.autofit columns("b:b").entirecolumn.autofit columns("c:c").entirecolumn.autofit : msgbox count end sub
below page source page trying pull from. need printer status "sleep mode " in example, toner level "41%" in example, , image unit life remaining "75%" in example.
<html> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <meta http-equiv="refresh" content="120; url=/cgi bin/dynamic/printer/printerstatus.html"> <title>printer status</title> <base target="_self"> <link rel="stylesheet" href="/cgi-bin/dynamic/printer/style_dell.css" type="text/css"> </head> <body> <!-- device status title--> <h3>device status - <a href="/" target="_top"><sub><b><font size="3">refresh</font></b></sub></a></h3> <hr class="status_hr"/> <!-- panel , toner level --> <table class="status_table"> <tr> <th colspan="4"> </th> </tr> <!-- panel --> <tr> <td colspan="4"><b>operator panel</b></td> </tr> <tr> <td colspan="4"> <table class="statusbox" width="140" height="40" cellspacing="0" bgcolor="#f8f8f8" cellpadding="2"> <tr> <td width="100%" class="statusline"><font face="courier" size="2">sleep mode     </font></td> </tr> <tr> <td width="100%" class="statusline"><font face="courier" size="2"></font></td> </tr> </table> </td> </tr> <!-- toner level --> <tr><td><b>black cartridge ~41%</b></td> </tr> <tr> <td width="23%"><img src="/images/black_40.png"/></td> </tr> </table> <hr class="status_hr"> <table class="status_table"> <tr> <th colspan="5"> </th> </tr> <tr> <td width="23%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>paper input tray:</b></p> </td> <td width="20%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>status:</b></p> </td> <td width="15%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>capacity:</b></p></td> <td width="15%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>size:</b></p></td> <td width="25%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>type:</b></td> </tr> <tr> <td><p style="margin-left:5">tray 1</p></td> <td width="30%"><p style="margin-left:5"><table width="50%" bgcolor="#96e7bc" style="padding: .75pt" height="1"><tr><td><b>ok</b></td></tr></table></p></td> <td><p style="margin-left:5">250</p></td> <td><p style="margin-left:5">letter</p></td> <td><p style="margin-left:5">plain paper</p></td> </tr> <tr> <td><p style="margin-left:5">tray 2</p></td> <td width="30%"><p style="margin-left:5"><table width="50%" bgcolor="#96e7bc" style="padding: .75pt" height="1"><tr><td><b>ok</b></td></tr></table></p></td> <td><p style="margin-left:5">550</p></td> <td><p style="margin-left:5">letter</p></td> <td><p style="margin-left:5">plain paper</p></td> </tr> <tr> <td><p style="margin-left:5">multi-purpose feeder</p></td> <td width="30%"><p style="margin-left:5"><table width="50%" bgcolor="ffffff" style="padding: .75pt" height="1"><tr><td><b>ok</b></td></tr></table></p></td> <td><p style="margin-left:5">50</p></td> <td><p style="margin-left:5">letter</p></td> <td><p style="margin-left:5">custom type 6</p></td> </tr> <tr> <td colspan="5"> </td> </tr> <tr> <td width="23%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>paper output bin:</b></p></td> <td width="20%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>status:</b></p> </td> <td width="15%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b>capacity:</b></p></td> <td width="15%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b></b></p></td> <td width="25%"><p align="left" style="margin-top: 5; margin-bottom: 5"><b></b></p></td> </tr> <tr> <td><p style="margin-left:5">standard bin</p></td> <td width="30%"><p style="margin-left:5"><table width="50%" bgcolor="#96e7bc" style="padding: .75pt" height="1"><tr><td><b>ok</b></td></tr></table></p></td> <td><p style="margin-left:5">150</p></td> <td><p style="margin-left:5"></p></td> <td><p style="margin-left:5"></p></td> </tr> </table> <hr class="status_hr"> <table class="status_table"> <tr> <th colspan="2"> </th> </tr> <tr> <td width="40%"><b>device type:</b></td><td width="60%">monochrome laser</td> </tr><tr> <td><b>speed:</b></td><td>up 40 pages/minute</td> </tr><tr> <td><b>toner cartridge capacity:</b></td><td>approximately 8,500 pages @ 5% coverage</td> </tr><tr> <td><b>imaging unit life remaining:</b></td><td>75%</td> </tr> </table> </body> </html>
if can working on 1 page, need find way not have open ie if that's possible. there around 60 printers need pull info from. assistance.
Comments
Post a Comment