有没有办法在磁盘上创建Excel文件?我无法使用典型的NewBook.SaveAs
因为我的文档管理系统挂钩会在存在SaveAs操作时抓取它。但是,我可以在磁盘上打开文档并使用原始文件名保存。
我可以使用我需要的ActiveWorkbook.Save
。
感谢。
答案 0 :(得分:0)
虽然目前还不清楚你正在尝试做什么(或为什么),但这可能是有用的,因为它不会调用SaveAs
或SaveCopyAs
(不确定后者是否对您的DMS有问题):
Dim sPath$, sFileName$, newFileName$
sPath = "C:\Path\Where\You\Want\YourFileSaved\"
sFileName = "MyExcelFile.xlsx"
'The Worksheet.Copy method will create a new Excel file
ActiveWorkbook.Worksheets(1).Copy
'Specify the path where you'd like the file to be
ChDir sPath
'Saves the file with default name e.g., "Book2.xlsx", etc.
ActiveWorkbook.Save
'Rename the file if needed, first get the file's default name:
newFileName = ActiveWorkbook.FullName
'Close it so we can rename it
ActiveWorkbook.Close
'Rename it:
Name newFileName As sFileName