我试图找出是否可以编写VBA来保存我打开的文件“filename”(在本例中为“PO_Cancellation_Issues - ”)+当前日期?因此,今天它将保存为“PO_Cancellation_Issues - 02192018”。我愿意接受任何保存mmddyyyy的日期格式。
感谢。
答案 0 :(得分:1)
以下内容如何:
Sub foo()
'FileExtStr = ".xlsb": FileFormatNum = 50
'FileExtStr = ".xlsx": FileFormatNum = 51
'FileExtStr = ".xlsm": FileFormatNum = 52
'FileExtStr = ".csv": FileFormatNum = 6
'FileExtStr = ".txt": FileFormatNum = -4158
'FileExtStr = ".prn": FileFormatNum = 36
FileFormatNum = 51
TempFilePath = Application.DefaultFilePath & "\"
Filename = "PO_Cancellation_Issues - "
TempFileName = Filename & " " & Format(Now, "mmddyyyy")
With ThisWorkbook
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
.Close SaveChanges:=False
End With
End Sub