Although I am very rusty on my VBA, I have saved sheets to new workbooks many times before. This code is failing with the error code "Method 'SaveAs' of object '_Workbook' failed"
wbSource.Sheets(newFileName).Copy
On Error GoTo NewWorkbookError:
Set wbCleaned = ActiveWorkbook
ChDir ProcessedFileStoragePath
wbCleaned.SaveAs filename:=newFilePath, _
FileFormat:=FileStoredAsFormat, CreateBackup:=False
It is failing with the same error with out the ChDir line, which I added since when recording a macro for saving the new workbook, that code line was in the recording.
The other thing I noticed was the "filename" casing in the .SaveAs method, which should be Filename: but the editor is lowercasing it when I type it in that way. I do NOT have any other variables in this module named filename.
Const ProcessedFileStoragePath As String = "C:\Users\TD\OneDrive\DataLoaders\FilesForAzureStorage\"
Const FileStoredAsFormat As String = "xlCSVUTF8"
Any help appreciated, I've spent too much time on this already.
newFilePath
andFileStoredAsFormat
would be helpful. – BigBen