Function GetFormattedDate strDate = CDate(Date) strDay = DatePart("d", strDate) strMonth = DatePart("m", strDate) strYear = DatePart("yyyy", strDate) If strDay < 10 Then strDay = "0" & strDay End If If strMonth < 10 Then strMonth = "0" & strMonth End If GetFormattedDate = strYear & "-" & strMonth & "-" & strDay End Function 'For example: the date string will be 2011-03-21 GetFormattedDate() Reference http://www.w3schools.com/vbScript/func_formatdatetime.asp
' This sentence is not work. 'Option Explicit Dim objExcel, strExcelPath, objSheet ' You need to create the Example.xls file first. strExcelPath = "c:\Scripts\Example.xls" ' Open specified spreadsheet and select the first worksheet. Set objExcel = CreateObject("Excel.Application") objExcel.WorkBooks.Open strExcelPath Set objSheet = objExcel.ActiveWorkbook.Worksheets(1) ' Modify a cell. row 3, col 2 objSheet.Cells(3, 2).Value = "Test" ' Add a row before row 5. objSheet.Range("B5").EntireRow.Insert ' Label the new rows. Row 4 is unchanged, ' but what was row 5 is now row 6. objSheet.Cells(4, 2).Value = "Row 4" objSheet.Cells(5, 2).Value = "Row 5" objSheet.Cells(6, 2).Value = "Row 6" ' Save and quit. objExcel.ActiveWorkbook.Save objExcel.ActiveWorkbook.Close objExcel.Application.Quit Check the file exist. If you want to do this. strFile = "c:\Scripts\Report.txt ' C...
Comments
Post a Comment