是否有任何VBA功能可以让我检查PC日期格式(区域设置)。这是在控制面板中设置的 - >地区和语言。
迈克尔
答案 0 :(得分:0)
我发现这几年我用它来检查区域日期格式:
Function DateFormat() As String
DateFormat = CStr(DateSerial(1999, 1, 2))
DateFormat = Replace(DateFormat, "1999", "YYYY")
DateFormat = Replace(DateFormat, "99", "YY")
DateFormat = Replace(DateFormat, "01", "MM")
DateFormat = Replace(DateFormat, "1", "M")
DateFormat = Replace(DateFormat, "02", "dd")
DateFormat = Replace(DateFormat, "2", "d")
DateFormat = Replace(DateFormat, MonthName(1), "MMMM")
DateFormat = Replace(DateFormat, MonthName(1, True), "MMM")
End Function
所以在我的设置中,函数返回:dd / MM / YYYY
答案 1 :(得分:0)
您可以{/ 3}}
Dim objExcel, strExcelPath, objSheet
'strValue=WScript.Auguments(0)
'arrValue=Split(strValue,"|")
Set WshSheel = CreateObject("WScript.Shell")
strExcelPath ="C:\Users\Z997710\Desktop\pension1.xlsx"
' Open specified spreadsheet and select the first worksheet.
Set objExcel = CreateObject("Excel.Application")
objExcel.WorkBooks.Open strExcelPath
Set objSheet = objExcel.ActiveWorkbook.Worksheets(3)
' Modify a cell.
'objSheet.Cells(2, 1).Value =20
objSheet.Cells(2, 1).Value =WScript.Auguments(0)
objSheet.Cells(2, 2).Value ="09/02/2015"
objSheet.Cells(2, 3).Value ="09/02/2020"
'objSheet.Cells(2, 1).Value =Trim(arrValue(0))
'objSheet.Cells(2, 2).Value =Trim(arrValue(0))
strValue=objSheet.Cells(12, 4).Value
objSheet.Cells(12, 5).Value = strValue
msgbox strValue
' Save and quit.`enter code here`
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
'WScript.Quit
HKEY_CURRENT_USER\Control Panel\Internationaly\
表示较长的日期,例如sLongDate
dddd, d. MMMM yyyy
代表短日期,例如sShortDate