Friday, April 9, 2010

VBScript - How Can I Convert a Number to a Date and Then Back in Excel?

VBScript - How Can I Convert a Number to a Date and Then Back in Excel?

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Add
Set objWorksheet = objWorkbook.Worksheets(1)

objExcel.Cells(1,1) = 31738
Wscript.Echo objExcel.Cells(1,1)

objExcel.Cells(1,1).NumberFormat = "m/d/yyyy"
Wscript.Echo objExcel.Cells(1,1)

objExcel.Cells(1,1).NumberFormat = ""
Wscript.Echo objExcel.Cells(1,1)

[Via]