title: Calling macro from VB script
body: <p>Hi I am trying to call a macro in test.xls using the following VB script</p>
  
  <pre><code>Option Explicit
  
  Dim returnVal 
  returnVal = 0
  WScript.Echo returnVal
  
  Dim xlApp, xlBook
  
  Set xlApp = CreateObject("Excel.Application")
  Set xlBook = xlApp.Workbooks.Open("D:\test.xls", 0, True)
  xlApp.Run "macro1"
  xlBook.Close false
  xlApp.Quit
  
  Set xlBook = Nothing
  Set xlApp = Nothing
  
  WScript.Echo returnVal
  ''WScript.Quit returnVal
  </code></pre>
  
  <p>The macro defined in test.xls is : </p>
  
  <pre><code>Dim returnVal as Boolean
  sub macro1()
     returnVal = 1
     Exit Sub
  ...
  End Sub
  </code></pre>
  
  <p>When I try to run the VB script I get a pop up window with value 0 (that is for the echo I am doing at the start). Then I get a pop up window with value 0 again. Looks like the value from the macro is not being returned. </p>
  
  <p>Where am I going wrong here. </p>
  
  <p>Thanks, 
  Monica</p>