Hello all -
I am trying to save a copy of a multi-sheet workbook as an XLSX file format, to a shared OneDrive folder, using variables to build the directory path and file name. Here is my code:
The file saves to the proper folder, as an XLSX, but I can't open it - the error message states the extension isn't correct for this file type. If I include "FileFormat:=51" where I build the path and file name, then the script gets a compile error, stating that the Named Argument not found.
I have this working when I only needed the active sheet saved, but my needs have changed, and I now require the entire workbook to be saved as a copy. Any help here would be much appreciated.
Thanks
I am trying to save a copy of a multi-sheet workbook as an XLSX file format, to a shared OneDrive folder, using variables to build the directory path and file name. Here is my code:
VBA Code:
Sub SaveWorkbook()
Dim strXLS As String, strXLSName As String
strXLS = "C:\Users\" & ActiveSheet.Range("B50").Value & "\OneDrive\PurchaseOrders\PurchaseOrders_ExcelCopies\2023 POs" & "\"
strXLSName = "PO-" & ActiveSheet.Range("G4").Value & ActiveSheet.Range("H4") & ".xlsx"
ActiveWorkbook.SaveCopyAs Filename:= _
strXLS & strXLSName
End Sub
The file saves to the proper folder, as an XLSX, but I can't open it - the error message states the extension isn't correct for this file type. If I include "FileFormat:=51" where I build the path and file name, then the script gets a compile error, stating that the Named Argument not found.
I have this working when I only needed the active sheet saved, but my needs have changed, and I now require the entire workbook to be saved as a copy. Any help here would be much appreciated.
Thanks