Avatar of Culwatrnca11
Culwatrnca11
Flag for United States of America

asked on 

Save Xlsx to xlsm file that has multiple tabs

I found this code to save xlsx to xlsm, it works great when there is only one sheet but I have files with multiple sheets and this vbs wont run. How do you modify this existing code to work with an excel file that has multiple tabs (sheets)?

if WScript.Arguments.Count < 2 Then
    WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsxToxlsm SourcePath.xlsx Destination.xlsm"
    Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.Worksheets(1).Activate
oBook.SaveAs WScript.Arguments.Item(1), 52
oBook.Close False
oExcel.Quit

Open in new window

Microsoft ExcelVB Script

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon