保存当前日期的宏

编程入门 行业动态 更新时间:2024-10-24 12:33:18
本文介绍了保存当前日期的宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有办法让宏保存当前名字中的文件。我想保存这个关于日期的正确的日期。

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

更多推荐

保存当前日期的宏

本文发布于:2023-10-31 07:22:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545420.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!