Save Xlsm file as xlsx

前端 未结 1 1611
甜味超标
甜味超标 2021-01-24 12:56

I want to save the current xlsm file as xlsx, so i wrote a code as below. This code really done it job and i able to see the file saved as Myfile.xlsx as what i\'ve defined in t

1条回答
  •  时光说笑
    2021-01-24 13:40

    This will avoid the extra copy:

    Sub saveAsXlsx()
        Dim myPath As String
        myPath = Application.ActiveWorkbook.Path
        Worksheets(Array("sheet1", "sheet2")).Copy
        ActiveWorkbook.SaveAs Filename:=myPath & "\Myfile.xlsx"
        ActiveWorkbook.Close
    End Sub
    

    This uses SaveAs rather than SaveCopyAs since you already have created the first copy.

    0 讨论(0)
提交回复
热议问题