1004 Error- issues with SaveAs

本秂侑毒 提交于 2019-12-02 05:28:00

The problem may be with ActiveWorkBook. You should try to avoid relying on .Active, .Activate, and .Select when you can simply refer to your objects directly.

Delete wbTarget.Activate and try the below,

WbTarget.SaveAs Filename:=myFileName, FileFormat:=xlOpenXMLWorkbook

I can see you have tried to debug. MsgBox myFileName (notice: no ()) should have displayed what you are passing to the save command. From your code above, it would be \\local drive pathWorkbook Name - noting that there is a space at the end as well. You have not defined saveDate, you have not added an extension and you have not indicated the file format.

See the following answers for further information to SaveAs.

How to do a "Save As" in vba code, saving my current Excel workbook with datestamp?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!