[英]Save file in excel using VBA
I recoreded a macro of me saving a file, but I want the name of the file to be 我重新整理了保存文件的宏,但我希望文件名是
"OOR" & " " & Date & " " & Time “ OOR”&“”&日期&“&时间
so the output should be OOR 10.18.2017 07:38 AM 因此输出应为OOR 10.18.2017 07:38 AM
Can someone help me with the code? 有人可以帮助我提供代码吗? Greatly apreciate it:
非常感谢:
ChDir "C:\Users\spall1\Desktop\Base Business\Base Business Report\OOR Report"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\spall1\Desktop\Base Business\Base Business Report\OOR Report\OOR & DATE & TIME.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
You need to close the constant String part with "
before adding the variable of Date
and Time
. 在添加
Date
和Time
变量之前,您需要先使用"
关闭常量String部分。
Change the last part of the string from: 从以下位置更改字符串的最后一部分:
\OOR & DATE & TIME.xlsx"
to: 至:
\OOR" & Date & Time & ".xlsx"
Or , you could use VBA Now
, which will give you both Date
and Time
: 或者 ,您可以使用VBA
Now
,它将为您提供Date
和Time
:
\OOR" & Now & ".xlsx"
:
ActiveWorkbook.SaveAs _
Filename:= _
"C:\Users\spall1\Desktop\Base Business\Base Business Report\OOR Report\OOR " & Format(Now(), "YYYY-MM-DD HHMM") & ".xls" _
, FileFormat:=xlOpenXMLWorkbook _
, CreateBackup:=False
:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.