vba - Fetch Data into Excel from batch file using vbs script -
vba - Fetch Data into Excel from batch file using vbs script -
i have batch file run set of sql queries , loads info table.
i have written vba script button click in excel retrieve info above table.
however requirement has changed populate info excel without button click. not want code in workbook open event.
i have alter vba code .vbs script can phone call batch file. please help me. right me if wrong approach.
write vbscript that:
executes bat
shell.run """c:\...\my.bat"""
then executes macro (example below)
runmacro sub runmacro() dim xl dim xlbook dim scurpath path = createobject("scripting.filesystemobject").getabsolutepathname(".") set xl = createobject("excel.application") set xlbook = xl.workbooks.open(path & "\workbook.xlsm", 0, true) xl.application.visible = false xl.displayalerts = false xl.application.run "workbook.xlsm!module.runmacro" xl.activewindow.close xl.quit set xlbook = nil set xl = nil end sub
excel vba excel-vba batch-file vbscript
Comments
Post a Comment