对象工作表的运行时错误“ 1004”副本失败

时间:2018-08-08 09:53:17

标签: excel excel-vba

我遇到了这个问题:
我试图保存带有宏的备注模板。但是,当我打开新的Excel时,备注模板将遵循,但代码不会。因此,我将备忘录模板另存为Excel加载项。但是,当我将宏分配给按钮时,会出现错误消息:

  

对象工作表的运行时错误“ 1004”副本失败

enter image description here

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

enter image description here

0 个答案:

没有答案