closures文件时无法禁止剪贴板警告消息

我有一个macros打开工作簿(wb1)并将其复制到另一个工作簿(wb2),然后closureswb1。 不过,我总是提示下面的消息,有大量的剪贴板数据,我不希望被提示。 在做了一些研究后,我发现把'Application.CutCopyMode'设置为false(清除剪贴板)将解决这个问题,但是它没有。

Application.CutCopyMode = False ... 'copy the range from source book wb1.Worksheets("Sheet1").Range("A1:V2").Copy 'paste the data on the target book wb2.Worksheets("Sheet1").Range("A1:V2").PasteSpecial wb.Close savechanges:=False 

在这里输入图像说明

如何在没有此消息的情况下closures文件?

如果要禁止任何消息,请在closures文件之前添加以下内容:

Application.DisplayAlerts = False

如果要清除剪贴板内容,则应在执行复制/粘贴操作后添加Application.CutCopyMode = False 。 喜欢这个:

 ... 'copy the range from source book wb1.Worksheets("Sheet1").Range("A1:V2").Copy 'paste the data on the target book wb2.Worksheets("Sheet1").Range("A1:V2").PasteSpecial Application.CutCopyMode = False wb.Close savechanges:=False 

什么是你想要做的特殊粘贴? 如果您只是想复制这些值,那么不要复制和粘贴,而是直接赋值:

 wb2.Worksheets("Sheet1").Range("A1:V2").value = wb1.Worksheets("Sheet1").Range("A1:V2").value