我正在尝试将使用工作簿对象指定的工作簿保存为文件格式csv但存在一些问题。在下面的代码中,我在save-as行之后收到一个错误,说.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
答案 0 :(得分:0)
您应将其更改为:sSaveWorkbookAsCSV(c,“C:\ Testing.csv”)