excel vba - how can to handle the erorr: Run-time error '53' File not found -
it appears when use next code, when try start batch file excel.
sub runbatch() call shell(environ$("comspec") & " f:\financial\data\reports\expensesytd\batch1.bat", vbnormalfocus) end sub
i have error:
erorr: run-time error '53' file not found
how can solve issue?
what result both
dir /b "f:\financial\data\reports\expensesytd\batch1.bat" dir /b f:\financial\data\reports\expensesytd\batch1.bat
as not know file run-time error '53'
error message refers to, make public environ$("comspec")
result e.g. msgbox
, check output dir /b %comspec%
.
and consider change cmd calling /c
in syntax follows:
call shell(environ$("comspec") & " /c f:\financial\data\reports\expensesytd\batch1.bat", vbnormalfocus) 'or call shell("cmd /c f:\financial\data\reports\expensesytd\batch1.bat", vbnormalfocus)
the /c
argument ensures cmd window automatically closed when batch file finishes executing
Comments
Post a Comment