我遇到了这个问题:
我试图保存带有宏的备注模板。但是,当我打开新的Excel时,备注模板将遵循,但代码不会。因此,我将备忘录模板另存为Excel加载项。但是,当我将宏分配给按钮时,会出现错误消息:
对象工作表的运行时错误“ 1004”副本失败
Sub Test()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Worksheets("Sample1")
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
Dim Sheetname As String
With ActiveSheet
Sheetname = InputBox("Enter name of this Worksheet")
.Name = Sheetname
End With
End Sub
错误为msg的行为ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
excel文件名为book1.xlsm