title: VBS - Trying to prevent a Text String conversion to Date
body: <p>I am using a VB script to convert a CSV file to a Tab Delimited (txt) format.  In the txt result file there are several values that were converted to a date format and then saved as a number representing a date (ie: 703359).  The best fix I could come up with was adding .NumberFormat = "@" 
  to the With criteria.  This at least changes the number representation to a date (Aug-01) in the output.</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Thanks,
  Chris.</p>
  
  <p>Call of the VB script from Stored Procedure in SQL:
  //SQL "Call":
      exec master..xp_cmdshell 'c:\byr\CSVtoTAB_SKUCodeProtected.vbs C:\byr\SkusOrdered.csv C:\byr\SkusOrdered.txt
  
  <p>// VB Code begins:</p>
  
  <pre><code>if WScript.Arguments.Count &lt; 2 Then
  '    WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
      Wscript.Quit
  End If
  Dim oExcel
  Dim oBook
  Dim oSheet
  Set oExcel = CreateObject("Excel.Application")
  Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
  Set oSheet = oBook.Sheets(1)
  With oSheet
      .Columns(1).NumberFormat = "@"
  End With
  oBook.SaveAs WScript.Arguments.Item(1), 20
  oBook.Close False
  oExcel.Quit
  SET oBook = NOTHING
  SET oExcel = NOTHING
  'WScript.Echo "Done"
  </code></pre>
  
  <p>//Sample Data:</p>
  
  <pre><code>OrderNum    Sku Description Qty
  12988   MHT1101 2010 LBB MANHATTAN  2
  12998   MHT1101 2010 LBB MANHATTAN  1
  13034   Aug-01  2010 LYB AUGUSTA    3  &lt;-- One of the offending SKU's
  13072   ATA2101 2010 LYB ATLANTA    1
  13102   MHT1101 2010 LBB MANHATTAN  4
  13115   MHT1101 2010 LBB MANHATTAN  5
  </code></pre>