title: VBA to VBS for ActiveWorkbook
body: <p>I'm trying to convert some VBA code that I embed in Excel spreadsheets to save all tabs as CSVs into a VBS script that I can run from command line to do the same thing.</p>
  
  <pre><code>Set objFSO = CreateObject("Scripting.FileSystemObject")
  src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
  Dim oExcel
  Set oExcel = CreateObject("Excel.Application")
  Dim oBook
  Set oBook = oExcel.Workbooks.Open(src_file)
  Dim worksheetCount
  workSheetCount = oExcel.Worksheets.Count
  oExcel.DisplayAlerts = False
  Dim counter
  Dim currentWorkSheet
  For counter = 1 to workSheetCount
      Set currentWorkSheet = oBook.Worksheets(counter)
      currentWorkSheet.Copy
      oExcel.ActiveWorkbook.SaveAs oBook &amp; "-" &amp; currentWorkSheet.Name &amp; ".csv", 6
      oExcel.ActiveWorkbook.Close False
      ThisWorkbook.Activate
  Next    
  oExcel.DisplayAlerts = True
  oBook.Close False
  oExcel.Quit
  </code></pre>
  
  <p>The error occurs at the beginning of line "oExcel.ActiveWorkbook.SaveAs" and says object doesn't support this method. So I assume the Excel object doesn't have the ActiveWorkbook method? Is there a VBA->VBS conversion here, some other method I should be using?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This works for me now:</p>
  
  <pre><code>Set objFSO = CreateObject("Scripting.FileSystemObject")
  src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
  
  Dim oExcel
  Set oExcel = CreateObject("Excel.Application")
  
  Dim oBook
  Set oBook = oExcel.Workbooks.Open(src_file)
  
  Dim WshShell
  Set WshShell = CreateObject("WScript.Shell")
  
  Dim strCurDir
  strCurDir = WshShell.CurrentDirectory &amp; "\" &amp; oBook.Name &amp; "-"
  
  Dim worksheetCount
  workSheetCount = oExcel.Worksheets.Count
  
  oExcel.DisplayAlerts = False
  
  Dim counter
  Dim currentWorkSheet
  For counter = 1 to workSheetCount
      Set currentWorkSheet = oBook.Worksheets(counter)
      currentWorkSheet.Copy
      oExcel.ActiveWorkbook.SaveAs strCurDir &amp; currentWorkSheet.Name &amp; ".csv", 6
      oExcel.ActiveWorkbook.Close False
  Next
  
  oExcel.DisplayAlerts = True
  oBook.Close False
  oExcel.Quit
  </code></pre>