I've got a workbook that uses a macro to run a batch file (CEA.bat) via. the Shell function. I created the workbook on my local D: drive (C: is the main/OS partition), and it works fine there.
I'd like to share copies of the workbook with my colleagues, but the shell function only seems to work in the drive in which it was created (D:). If I create a copy of the workbook under another directory in the original drive (D:), it still works. If I create a copy in another drive (e.g. C:) or on another machine, the Shell function will not run the batch file.
The batch file and workbook are always saved in the same folder. The batch file works fine if I run it directly, so I don't think there's an issue with it. The issue seems to be related to the Shell function. The relevant lines of code are shown below:
Dim CEArun As String
ChDrive ThisWorkbook.Path
ChDir ThisWorkbook.Path
CEArun = Chr(34) & ThisWorkbook.Path & "\CEA.bat"& Chr(34)
Call Shell(CEArun, vbMinimizedNoFocus)
I'm pretty new to VBA, and what I do know is self-taught, so I could be missing something really obvious.
I've come across another way to run batch files in VBA using the WshShell object, but I haven't tried it yet. It seems like it would only work if the "Windows Script Host Object Model" is activated. My colleagues have even less VBA knowledge than I do, so I'd prefer to give them a tool they can use without having to mess around with VBA settings.
If I've neglected any important information, please let me know. I appreciate any help you can offer!