Saturday, 15 May 2010

textbox - Excel Noob Copy Excel Cell to HTML text box -



textbox - Excel Noob Copy Excel Cell to HTML text box -

i have re-create on weekly bases 500-600 cells website covered in textboxes. know how code know how read source code excel beyond me right now. how can re-create excel cell placed in text field (i have broken downwards below). i'll need help having repeat until nail blank cell.

a1 = id='firstname0' a2 = id='middleinitial0' a3 = id='lastname0' a6 = id='ntlogin0' b1 = id='firstname1' b2 = id='middleinitial1' b3 = id='lastname1' b6 = id='ntlogin1' c1 = id='firstname2' c2 = id='middleinitial2' c3 = id='lastname2' c6 = id='ntlogin2'

here of source of site:

class="lang-html prettyprint-override"><td> <input type='text' name='ntlogin[]' id='ntlogin0' /> </td> <td> <input type='text' name='firstname[]' id='firstname0' /> </td> <td class='center'> <input type='text' name='middleinitial[]' id='middleinitial0' size='1' /> </td> <td> <input type='text' name='lastname[]' id='lastname0' /> </td> <td> <input type='text' name='hiredate[]' id='hiredate0' /> </td>

the site asks me how many rows create. hire date section can command 1 button push. can not command website can't create changes it.

you can utilize vba library "microsoft net controls" , "microsoft html object library" , automate web page interaction...

below macro it... come in macro code, can utilize alt+f11 come in microsoft visual basic applications environment. - add together library references (under tools>references menu) - add together code module (under insert>module) - paste code below... modify url

the code open ie go web page , wait nail ok (after have done whatever need.. maybe logging in, navigating somewhere, entering number of rows, ...). loop through columns have used in spreadsheet (using find populate numcols) , drop cell values html elements relevant ids. won't nail add employees you, in case went wrong, library give ability .click() on things.

i've used few automation hacks , seems quite reliable... hard parts can waiting page loads/updates - shouldn't have problem.

'references needed: "microsoft net controls" , "microsoft html object library" ' (add under menu tools > references) sub populate() dim ws worksheet set ws = application.activesheet dim appie internetexplorer set appie = new internetexplorer appie.visible = true appie.navigate "http://localhost:8080/your_form" if vbcancel = msgbox("make sure page has loaded, come in number of ids etc. etc. click ok", vbokcancel) set appie = nil exit sub end if dim counter integer, index integer, numcols integer numcols = ws.cells.find(what:="*", after:=[a1], lookin:=xlvalues, searchorder:=xlbyrows, searchdirection:=xlprevious).column counter = 1 numcols 'a1 = id='firstname0' 'a2 = id='middleinitial0' 'a3 = id='lastname0' 'a6 = id='ntlogin0' index = counter - 1 appie.document.getelementbyid("firstname" & index).value = ws.cells(1, counter) appie.document.getelementbyid("middleinitial" & index).value = ws.cells(2, counter) appie.document.getelementbyid("lastname" & index).value = ws.cells(3, counter) appie.document.getelementbyid("ntlogin" & index).value = ws.cells(6, counter) next counter set appie = nil set ws = nil msgbox "all done - nail submit if ok!" end sub

version values in rows

'references needed: "microsoft net controls" , "microsoft html object library" ' (add under menu tools > references) sub populate() dim ws worksheet set ws = application.activesheet dim appie internetexplorer set appie = new internetexplorer appie.visible = true appie.navigate "http://localhost:8080/your_form" if vbcancel = msgbox("make sure page has loaded, come in number of ids etc. etc. click ok", vbokcancel) set appie = nil exit sub end if dim counter integer, index integer, numrows integer numrows = ws.cells.find(what:="*", after:=[a1], lookin:=xlvalues, searchorder:=xlbyrows, searchdirection:=xlprevious).row counter = 1 numrows 'a1 = id='firstname0' 'b1 = id='middleinitial0' 'c1 = id='lastname0' 'd1 = id='ntlogin0' index = counter - 1 appie.document.getelementbyid("firstname" & index).value = ws.cells(counter,1) appie.document.getelementbyid("middleinitial" & index).value = ws.cells(counter,2) appie.document.getelementbyid("lastname" & index).value = ws.cells(counter,3) appie.document.getelementbyid("ntlogin" & index).value = ws.cells(counter,4) next counter set appie = nil set ws = nil msgbox "all done - nail submit if ok!" end sub

excel textbox webpage

No comments:

Post a Comment