我有一段代码,其中应该将工作簿保存为文件路径+前缀+用户输入的任何日期。日期输入应采用MMDDYYYY格式。问题是VBA转换日期并将其保存为MM-DD-YYYY格式。我怎么才能阻止这一切。
我的代码:
With prevdaily
Application.DisplayAlerts = False
' Check for year folder and create if needed
If Len(Dir("G:\AccPac ERP Daily Reports\" & Year(Date), vbDirectory)) = 0 Then
MkDir "G:\AccPac ERP Daily Reports\" & Year(Date)
End If
' Check for month folder and create if needed
If Len(Dir("G:\AccPac ERP Daily Reports\" & Year(Date) & "\" & Format(Date, "mm ") & MonthName(Month(Date), False), vbDirectory)) = 0 Then
MkDir "G:\AccPac ERP Daily Reports\" & Year(Date) & "\" & Format(Date, "mm ") & MonthName(Month(Date), False)
End If
fname2 = InputBox("Please enter date of Daily Income Journal to save")
fname2 = fname2 & ".xlsx"
fpath = "G:\AccPac ERP Daily Reports\" & Year(Date) & "\" & Format(Date, "mm ") & MonthName(Month(Date), False) & "\"
ActiveWorkbook.SaveAs FileName:=fpath & "Daily Income Journal-" & fname谢谢你巴兰卡!
发布于 2014-07-28 01:30:12
我认为您可以使用format()函数创建一个具有所需格式的字符串:
示例:
Dim strDate as String
strDate = format(Date, "mmddyyyy")阅读:
https://stackoverflow.com/questions/24987330
复制相似问题