Getting “method saveas of object _workbook failed” error while trying to save an XLSM as CSV

后端 未结 5 2321
难免孤独
难免孤独 2020-12-10 12:20

I\'m trying to save a macro-enabled Excel workbook as a csv file, overwriting the old one (below I had to change the name of the folder and the Sheet, but that doesn\'t seem

5条回答
  •  囚心锁ツ
    2020-12-10 13:15

    Try combining the Path and the CSV file name into a string variable and drop the .csv; that is handled by the FileFormat. Path must be absolute starting with a drive letter or Server Name: Dim strFullFileName as String strFullFileName = "C:\My Folder\My_Sheet" If on a Server then it would look something like this: strFullFileName = "\\ServerName\ShareName\My Folder\My_Sheet" Substiture ServerName with your Server name and substitute ShareName with the your network Share name e.g. \\data101\Accounting\My Folder\My_Sheet ActiveWorkbook.SaveAs Filename:=strFullFileName,FileFormat:=xlCSVMSDOS, CreateBackup:=False

提交回复
热议问题