我正在尝试编写一个代码,用于保存我的工作表,标题为“EMM POS Breaks TD 上一个工作日 ....所以例如今天我需要它保存为”EMM POS打破了TD 10.01.15“...我在网上找到了一些代码,它正在保存并且日期功能正在运行,但它没有将工作簿保存为excel文件。任何人都可以详细说明我能做什么谢谢!
'x = Weekday(Today, vbSunday)
'Select Case x
' Case 1
' x = 2
' Case 2
' x = 3
' Case Else
' x = 1
'End Select
'ActiveWorkbook.SaveAs Filename:="EMM Position Breaks TD " & _
' Format(Date - x, "mm.dd.yyyy") & " ", FileFormat:=xlNormal, Password:="", _
' WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
答案 0 :(得分:0)
要将文件另存为 *。xlsx ,您需要将FileFormat
指定为 xlOpenXMLWorkbook
:
x = Weekday(Today, vbSunday)
Select Case x
Case 1
x = 2
Case 2
x = 3
Case Else
x = 1
End Select
ActiveWorkbook.SaveAs Filename:="EMM Position Breaks TD " & _
Format(Date - x, "mm.dd.yyyy") & ".xlsx", FileFormat:=xlOpenXMLWorkbook, Password:="", _
WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
至于扩展程序,您可以按照评论中的建议添加它:Filename:="EMM Position Breaks TD " & Format(Date - x, "mm.dd.yyyy") & ".xlsx"
。