我正在尝试将使用工作簿对象指定的工作簿保存为 csv 文件格式,但有一些问题。在下面的代码中,我在另存为行之后收到一个错误,说 .csv 文件是只读的:
Sub Button1_Click()
Dim c As Workbook
Set c = Application.Workbooks.Open(Filename:="C:\Testing\testbook.xlsx", IgnoreReadOnlyRecommended:=True)
Call sSaveWorkbookAsCSV(c, "C:\Testing")
End Sub
Public Sub WBookToCSV(wkbktosv As Workbook, strOutputFilePath As String)
Application.DisplayAlerts = False
Call wkbktosv.SaveAs(strOutputFilePath, xlCSV, CreateBackup:=False)
Application.DisplayAlerts = True
Call wkbktosv.Close(SaveChanges:=False)
End Sub