vbscript update excel spreadsheet -
i've looked on many sites, including questions came when entered title, , can't seem program work. activates spreadsheet, no data prints.
option explicit dim objexcel, objworkbook dim strtin, strname, strfname, strlname, strstate, strempid, strrecdate, strcomment set objexcel = createobject("excel.application") set objworkbook = objexcel.workbooks.open("c:\users\lpeder6\desktop\important info\data tracking.xlsx") copydata set objexcel = nothing set objworkbook = nothing '---------------copydata - copies required data----------------- sub copydata() strtin = "2-123456789-00005" strname = "smith john " strstate = "mn" strempid = "s987654321" strrecdate = "04/02/2015" strcomment = "this in comment." strlname = trim(left(strname, 10)) strfname = trim(right(strname, 15)) strname = strlname & " " & strfname objexcel.visible = true objworkbook.sheets(1).activate objworkbook.sheets(1).cells(1, 1).value = strtin objworkbook.sheets(1).cells(1, 2).value = strname objworkbook.sheets(1).cells(1, 3).value = strstate objworkbook.sheets(1).cells(1, 4).value = strempid objworkbook.sheets(1).cells(1, 5).value = strrecdate objworkbook.sheets(1).cells(1, 6).value = strcomment objexcel.activeworkbook.close end sub
any ideas appreciated.
by 'no data prints', i'm assuming mean data input not stored. because not saving workbook close it. change 1 line in sub to:
objexcel.activeworkbook.close true
see workbook.close method (excel) full syntax reference.
Comments
Post a Comment