ManhattanJM
New Member
- Joined
- Feb 19, 2022
- Messages
- 6
- Office Version
- 2016
- Platform
- MacOS
Hi,
I'm trying to convert tabs into separate csv files, but I'm encountering a Run time error 1004 : Cannot access read-only document with the name of the first tab. Below is my code, please help point me in the right direction. Thank you!
I'm trying to convert tabs into separate csv files, but I'm encountering a Run time error 1004 : Cannot access read-only document with the name of the first tab. Below is my code, please help point me in the right direction. Thank you!
VBA Code:
Sub exportcsv()
Dim ws As Worksheet
Dim path As String
path = ActiveWorkbook.path & "\" & Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1)
For Each ws In Worksheets
ws.Activate
ActiveWorkbook.SaveAs FileName:=path & "_" & ws.Name & ".csv", FileFormat:=xlCSVUTF8, CreateBackup:=False
Next
End Sub