I am trying to save a workbook specified using a workbook object as file format csv but having a few problems. In the below code, I get an error after the save-as line, saying the .csv file is read-only:
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
You should change it to: sSaveWorkbookAsCSV(c, “C:\Testing.csv”)