title: VBA - Execute or Run .bat File Inside Macro
body: <p>I have been attempting to automate a series of administrative events for some of the users where I work by creating scripts and macro's and so on.. </p>
  
  <p>These scripts and macros work great, however, I would like to make a the process even easier for the users by running a single batch file that will systematically execute the scripts and macros.</p>
  
  <p>The batch file I currently have, calls all the scripts one by one, and the very last script opens one of the xlsm workbooks which contains a few macro's in it - and here is where the issue is - There are still scripts to be executed but they can only be executed once this workbook has executed all its macros.</p>
  
  <p>So my initial thought was to test if the workbook is open, if it is, delay the execution of the next script by a minute or so, then test again and again... until it is closed.. Then I thought perhaps it would be easier to execute the next set of scripts (also in a batch file) from within a macro.</p>
  
  <p>So, I have this code:</p>
  
  <pre><code>Sub Run_BAT()
  
      Set obj = CreateObject("Wscript.Shell")
  
      obj.Run Chr(34) &amp; "X:\Test\" &amp; "Termination Reports Scripts\" &amp; "Execute_Terminations.bat" &amp; Chr(34), 0, True
  
      Set obj = Nothing
  
  End Sub
  </code></pre>
  
  <p>Which gives me an error: </p>
  
  <blockquote>
    <p>Permission Denied</p>
  </blockquote>
  
  <p>Then there's this code:</p>
  
  <pre><code>Sub WriteAndRunBatFile()
  
  Call Shell("X:\Test\Termination Reports Scripts\Execute_Terminations.bat")
  
  End Sub
  </code></pre>
  
  <p>Which gives me the error: </p>
  
  <blockquote>
    <p>Invalid procedure call</p>
  </blockquote>
  
  <p>Any and every single code sample that contains the "Shell" command gives this error.</p>