简体   繁体   中英

VBA to save an excel sheet including its macro

I want to write a macro that saves a sheet on a new workbook including the macro that are in this sheet. But I fail, the new workbook is an macro enabled workbook, but the buttons inside are reffering to the macro that are on the original file :-(

How can I copy the macro in the new workbook ? The macro to be copied is called "my_macro"

Below is the code I currently use that fails:

Sub aSaveout()

Sheets("mysheet").Select
ActiveSheet.Copy
'ThisFile = Range("A1").Value
ActiveSheet.SaveAs Filename:="mysheet.xlsm", FileFormat:=52
Application.ScreenUpdating = True
ActiveWorkbook.Close

End Sub

Thanks

感谢您的参与> Jeeped是正确的,activeX控件可以正常工作并导出到新保存的文件中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM