title: VBS runs VBA Macros in .xlsm workbook fine on one server but not another
body: <h2>Issue:</h2>
  
  <hr>
  
  <p>I have a VBScript that opens a .xlsm workbook and executes a few macros.
  The code in the VBScript &amp; VBA macros have all been tested and works perfectly, but only on 1 server, the "Production" server. </p>
  
  <p>When attempting to run the VBS on a second server, the "Test" server, the VBS successfully opens the workbook and successfully executes a preliminary macro to gather process information, but then it hits a very cryptic error when attempting to execute the second macro titled "Auto_Run", after that the VBS closes the workbook and executes the rest of its code perfectly.</p>
  
  <p><strong>Why would this work fine on one server but not the other? Where do I start to troubleshoot this?</strong></p>
  
  <p>If you think you can help but need me to provide something more, by all means please say so and I will provide it.</p>
  
  <hr>
  
  <h2>Details:</h2>
  
  <hr>
  
  <p>The preliminary macro that works is actually 'GetCurrentProcessID' from kernel32. Added to the macro via this line of code:</p>
  
  <pre><code>Declare PtrSafe Function GetCurrentProcessId Lib "kernel32" () As Long
  </code></pre>
  
  <p>The cryptic error returned from the VBScript when attempting to execute the 2nd Macro: "Auto_Run" on the "Test" server is:</p>
  
  <pre><code>Err.Source = ""
  Err.Code = -2147417851
  Err.Description = "&lt;Error&gt; | -2147417851: &lt;/Error&gt;"
  </code></pre>
  
  <p>The Sub for the second Macro 'Auto_Run':</p>
  
  <pre><code>Sub Auto_Run()
      On Error GoTo e
      QLog "'Auto_Run' Starting..."
      modMain.bAuto = True
  
      Main bAuto
  
  QLog "'Auto_Run' Completed."
  x:
      Exit Sub
  e:
      QLog "'Auto_Run' " &amp; Get_Err
      Resume x
  End Sub
  </code></pre>
  
  <p>QLog is a sub that writes the contents of the string parameter passed to it to 3 places, 1 the status bar, 2 a progress indication form (that is only displayed optionally when executed manually) &amp; 3, most importantly, to a database log table.</p>
  
  <p>The second executable line of "Auto_Run" doesn't even execute:</p>
  
  <pre><code>        QLog "'Auto_Run' Starting..."
  </code></pre>
  
  <p>should log to the database log table, but of course it is empty.</p>
  
  <hr>
  
  <h2>Event Viewer:</h2>
  
  <hr>
  
  <p>I checked the Application Log in Event Viewer and found 3 related events.</p>
  
  <p>1 'Application Error' type event:</p>
  
  <pre><code>Faulting application name: EXCEL.EXE, version: 14.0.7177.5000, time stamp: 0x582c88af
  Faulting module name: VBE7.DLL, version: 7.0.16.40, time stamp: 0x57fbbbf8
  Exception code: 0xc0000005
  Fault offset: 0x000000000000278d
  Faulting process id: 0x1c0c
  Faulting application start time: 0x01d2710609568608
  Faulting application path: C:\Program Files\Microsoft Office\Office14\EXCEL.EXE
  Faulting module path: C:\PROGRA~1\COMMON~1\MICROS~1\VBA\VBA7\VBE7.DLL
  Report Id: 488b9548-dcf9-11e6-bf1b-3a017bdb52e6
  </code></pre>
  
  <p>1 'Windows Reporting Error' information type event:</p>
  
  <pre><code>Fault bucket , type 0
  Event Name: APPCRASH
  Response: Not available
  Cab Id: 0
  
  Problem signature:
  P1: EXCEL.EXE
  P2: 14.0.7177.5000
  P3: 582c88af
  P4: VBE7.DLL
  P5: 7.0.16.40
  P6: 57fbbbf8
  P7: c0000005
  P8: 000000000000278d
  P9: 
  P10: 
  
  Attached files:
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\2\CVRA045.tmp.cvr
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERA9F5.tmp.appcompat.txt
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERAB0F.tmp.WERInternalMetadata.xml
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERAB2F.tmp.hdmp
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERADA0.tmp.mdmp
  
  These files may be available here:
  C:\Users\&lt;redacted&gt;\AppData\Local\Microsoft\Windows\WER\ReportQueue\AppCrash_EXCEL.EXE_33353b1e5e166abad4dbe725c82a3feea72c43_cab_be21aeb6
  
  Analysis symbol: 
  Rechecking for solution: 0
  Report Id: c39d1908-dcfb-11e6-bf1b-3a017bdb52e6
  Report Status: 4
  </code></pre>
  
  <p>and lastly 1 more 'Windows Error Reporting' information type:</p>
  
  <pre><code>Fault bucket 422681129, type 28
  Event Name: APPCRASH
  Response: Not available
  Cab Id: 0
  
  Problem signature:
  P1: EXCEL.EXE
  P2: 14.0.7177.5000
  P3: 582c88af
  P4: VBE7.DLL
  P5: 7.0.16.40
  P6: 57fbbbf8
  P7: c0000005
  P8: 000000000000278d
  P9: 
  P10: 
  
  Attached files:
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\2\CVRA045.tmp.cvr
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERA9F5.tmp.appcompat.txt
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERAB0F.tmp.WERInternalMetadata.xml
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERAB2F.tmp.hdmp
  C:\Users\&lt;redacted&gt;\AppData\Local\Temp\WERADA0.tmp.mdmp
  
  These files may be available here:
  C:\Users\&lt;redacted&gt;\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_EXCEL.EXE_33353b1e5e166abad4dbe725c82a3feea72c43_b759b319
  
  Analysis symbol: 
  Rechecking for solution: 0
  Report Id: c39d1908-dcfb-11e6-bf1b-3a017bdb52e6
  Report Status: 0
  </code></pre>
  
  <h2>What I have tried</h2>
  
  <hr>
  
  <p>I tried setting the Excel Application's Visible property to True
  &amp; adjusting the "Auto_Run" Sub to something much simpler to see if it would execute &amp; it did not.</p>
  
  <p>VBS:</p>
  
  <pre><code>oXL.Visible = True
  oXL.Application.Run "'" &amp; sName &amp; "'!" &amp; sMacro
  </code></pre>
  
  <p>VBA</p>
  
  <pre><code>Sub Auto_Run()
      'Test
      MsgBox "Help Me Please"
  End Sub
  </code></pre>
  
  <hr>
  
  <p><strong>Replies to Comments</strong></p>
  
  <hr>
  
  <p>Comintern   -</p>
  
  <pre><code>These servers are on the same network &amp; the program is being executed by the same AD User.
  What other permissions would I have to adjust?
  </code></pre>
  
  <p>ClintB  -</p>
  
  <pre><code>Running under the same AD user on the same network. Also, Excel is successfully opening &amp; executing the first macro, just not the 2nd one.
  
  -- Full Automation Works
  Prod Server OS: Windows Server 2008 R2 Standard SP1 - 64 bit
  Prod Server XL: 14.07177.5000 (32-bit)
  
  -- Doesn't work
  Test Server OS: Windows Server 2008 R2 Enterprise SP1 - 64 bit
  Test Server XL: 14.07177.5000 (64-bit)
  </code></pre>
  
  <p>Nick.McDermaid  -</p>
  
  <pre><code>Manual Execution on either server works as expected.
  </code></pre>
  
  <hr>
  
  <p>P.S.
  I apologize if this is a duplicate, but I haven't been able to find anything on this. I'm probably phrasing it poorly but I figured it was worth a shot to ask about it.</p>