title: Runnig a .bat file from within VB
body: <p>In Win 10 while running an Excel program, I have a button which executes a VB. module. In the module is the statement <code>Process.Start (&quot;Batfile.bat&quot;)</code>. Batfile.bat is in the same directory as the Excel file. Batfile's contents are simply</p>
  <pre><code>pause
  
  msg * List Created!
  </code></pre>
  <p>Here is the full code:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub Worksheets_to_txt()
  '&lt;--Saves each worksheet as a text file with the same name
  
      Dim CalcState As Long
      Dim EventState As Boolean
      Dim PageBreakState As Boolean
      
      Application.ScreenUpdating = False
  
  '    EventState = Application.EnableEvents
  '    Application.EnableEvents = False
  
      CalcState = Application.Calculation
      Application.Calculation = xlCalculationManual
  
      PageBreakState = ActiveSheet.DisplayPageBreaks
      ActiveSheet.DisplayPageBreaks = False
  
  
      Dim ws As Worksheet
      Dim relativePath As String
      Dim answer As VbMsgBoxResult
  
      relativePath = ActiveWorkbook.Path
      
  '    answer = MsgBox(&quot;Are you sure you want to export worksheets?&quot;, vbYesNo, &quot;Run Macro&quot;) '&lt;--Pop up box to confirm export
  
      Process.Start (&quot;Batfile.bat&quot;)
  
  '    If answer = vbYes Then
  
      Application.ScreenUpdating = False
      Application.DisplayAlerts = False
      For Each ws In ActiveWorkbook.Worksheets
  
          ws.Select
          ws.Copy
          ActiveWorkbook.SaveAs Filename:= _
          relativePath &amp; &quot;\&quot; &amp; ws.Name &amp; &quot;.txt&quot;, _
          FileFormat:=xlText, CreateBackup:=False
          ActiveWorkbook.Close
          ActiveWorkbook.Activate
      Next
  
      Worksheets(&quot;Master&quot;).Activate
      MsgBox &quot;Text files have been created.&quot;
  '     End If
      
      ActiveSheet.DisplayPageBreaks = PageBreakState
      Application.Calculation = CalcState
  '    Application.EnableEvents = EventState
      Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  <p>This runs fine when I execute it outside of Excel by itself, but pushing the button in excel gives me</p>
  <blockquote>
  <p>Run-time error &quot;424&quot;:</p>
  <p>Object Required</p>
  </blockquote>
  <p>I have tried a number of online remedies, but I keep getting the same result. What am I doing wrong?</p>