保存当前日期的宏 [英] Macro with Save Current date
本文介绍了保存当前日期的宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让宏保存当前名字中的文件。我想保存这个关于日期的正确的日期。
Is there a way to make a macro to save a file with the current day in the name. I want to save this off everyday with the correct date.
这是我作为一个宏,很简单,但是我有问题获取当前的日期公式在文件名中(如果可能)
This is what I have as a macro, pretty simple, but I am having issues with getting the current date formula in the file name (if possible)
Sub Save()
ActiveWorkbook.SaveAs Filename:="X:\file06-21-2012\.xlsm", FileFormat _
:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
所以明天我想要马可以保存为file06-22-2012。
So tomorrow i would want the marco to save it as file06-22-2012.
谢谢
推荐答案
像这样?
Sub Save()
Dim FilePath As String
Dim NewName As String
FilePath = "X:\": NewName = FilePath & "file" & Format(Date, "MM-DD-YYYY") & ".xlsm"
ActiveWorkbook.SaveAs Filename:=NewName, FileFormat _
:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
这篇关于保存当前日期的宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文