Tranfer excel sheet data to access table from excel vba giving error -
i'm trying tranfer excel sheet data access table. below code throws error variable not defind , pointing acimport . transferspreadsheet method works excel? alternate way there tranfer sheet data access excel.
private sub cal_wem_click() dim appaccess object dim apath, adbase, adsource, atable, exepath string dim fileparam string apath = activeworkbook.path adbase = "linear.accdb" adsource = apath & "\" & adbase set appaccess = createobject("access.application") appaccess.visible = true appaccess.opencurrentdatabase adsource appaccess.docmd.transferspreadsheet transfertype:=acimport, _ tablename:="yorno", _ filename:=apath, hasfieldnames:=true, _ range:="wem!d:e", spreadsheettype:=5 appaccess.docmd.openform "input_form_wem" application.displayalerts = false thisworkbook.saved = true application.quit exit sub end sub
worked out declaring variables this
const acimport = 0 const acspreadsheettypeexcel9 = 8 appaccess.docmd.transferspreadsheet acimport, acspreadsheettypeexcel9, _ "wemonoff1", ename, true, "wem-onoff!d:e"
Comments
Post a Comment