[英]How would I write VBA code to save an excel workbook with the filename as a cell value?
I have a workbook that will change weekly and I wanted to write a script that would save the workbook in a set location and change the name to what ever the start date of the week was.我有一个每周都会更改的工作簿,我想编写一个脚本,将工作簿保存在设定位置并将名称更改为一周的开始日期。
Any help would be greatly appreciated and if I am not being clear, I shall try and explain it better.任何帮助将不胜感激,如果我不清楚,我会尝试更好地解释它。
Thanks谢谢
You can do this using the Workbook.SaveAs
-method .您可以使用
Workbook.SaveAs
-method执行此操作。 The page I linked to explain what the different arguments you pass to the function do, the most pertinent one for you is the first one, Filename
, which you can set to be equal to just about any string (such as one retrieved from a cell).我链接的页面解释了您传递给函数的不同参数的作用,对您来说最相关的是第一个
Filename
,您可以将其设置为几乎等于任何字符串(例如从单元格中检索的字符串) )。 You can also (optionally) include a filepath preceding the filename, to determine where the file is saved, otherwise it is saved to the current folder.您还可以(可选)在文件名之前包含文件路径,以确定文件的保存位置,否则将保存到当前文件夹。
Workbook.SaveAs(FileName, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local)
You can assign the path and the file name to FileName
as String您可以将路径和文件名分配给
FileName
作为字符串
http://www.rondebruin.nl/win/s5/win001.htm http://www.rondebruin.nl/win/s5/win001.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.