Whenever I try to run code that I found online that apparently do this I get a error message.
Run-time error '-2147418113 (8000ffff)' Automation error Catastrophic failure
I've tried some modifications but I cant make it work, I've attached the unedited code I've been trying to make work. Any help would be greatly appriciated.
Public Sub SaveWorksheetsAsCsv()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
SaveToDirectory = "C:\Users\Name\OneDrive\Documents\test"
For Each WS In ThisWorkbook.Worksheets
WS.SaveAs SaveToDirectory & WS.Name, xlCSV
Next
End Sub