Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run bat file from Excel using VBA

I have test.bat file contains script:

copy host_name table_name -p table_name -t "file.csv"

Normally when I click on it, it's working fine. Now, I want to run test.bat file from Excel using vba.

strPath = ws1.Range("G2").value & "\" 'Directory to folder with bat
Shell strPath & "\test.bat", vbNormalFocus

something is wrong, because I see only snapshot/clip: like something is open and close into one sec...

like image 229
4est Avatar asked Oct 24 '25 15:10

4est


1 Answers

just resolved it:

ChDir ThisWorkbook.Path & "\folder\"
Shell ThisWorkbook.Path & "\folder\test.bat", vbNormalFocus
like image 53
4est Avatar answered Oct 27 '25 10:10

4est