I found code to save a single sheet as CSV. But I am getting error: Run-time error '1004' Cannot access read-only document 'MasterCallOneList.CSV'
How to fix?
The document is actually a new document that does not exist, so I don't know why it would say that the document is read-only.
Application.DisplayAlerts = False
Dim strFullName As String
strFullName = Application.Path + "\MasterOneCallList.CSV"
ThisWorkbook.Sheets("Combined").Copy
ActiveWorkbook.SaveAs Filename:=strFullName, FileFormat:=xlCSV, CreateBackup:=True
ActiveWorkbook.Close
Application.DisplayAlerts = True
Could be due to protection levels in the application.path directory.
Have you tried
Application.DisplayAlerts = False
Dim strFullName As String
strFullName = ThisWorkbook.Path + "\MasterOneCallList.CSV"
ThisWorkbook.Sheets("Combined").Copy
ActiveWorkbook.SaveAs Filename:=strFullName, FileFormat:=xlCSV, CreateBackup:=True
ActiveWorkbook.Close
Application.DisplayAlerts = True
strFullName = Application.Path + "\MasterOneCallList.CSV"
This could be the error, the path name would be the ms_office excel folder. Try using an actual folder path string and the code should work. If it does work, you would have to figure a way to get an actual path string.
Sub Button1_Click()
Dim strFullName As String
Application.DisplayAlerts = False
strFullName = "C:\Users\dmorrison\Downloads\TestKryztof" + "\MasterOneCallList.CSV"
ThisWorkbook.Sheets("Combined").Copy
ActiveWorkbook.SaveAs Filename:=strFullName, FileFormat:=xlCSV, CreateBackup:=True
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.