本文介绍了关闭工作簿中Excel VBA中的剪贴板提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个Excel工作簿,它使用VBA代码打开另一个工作簿,将一些数据复制到原始文件中,然后关闭第二个工作簿。 当我关闭第二个工作簿(使用 Application.Close ),我得到一个提示: VBA中是否有命令绕过此提示?解决方案我可以提供两个选项 直接复制 根据您的描述,我猜你正在做一些类似 设置wb2 = Application.Workbooks.Open(YourFile.xls) wb2.Sheets(YourSheet)。[< YourRange>]。 ThisWorkbook.Sheets(SomeSheet)。粘贴 wb2.close 如果是这种情况,您不需要通过剪贴板进行复制。此方法直接从源代码复制到目的地。 设置wb2 = Application.Workbooks.Open(YourFile.xls) wb2.Sheets(YourSheet)。[< YourRange>]。复制ThisWorkbook.Sheets(SomeSheet)。单元格(< YourCell) wb2.close 抑制提示 您可以通过设置 Application.DisplayAlerts来阻止所有警报弹出窗口= False 仅复制值:不要使用复制/粘贴 Dim rSrc As Range Dim rDst As Range 设置rSrc = wb2.Sheets(YourSheet)。范围(YourRange)设置rDst = ThisWorkbook.Sheets(SomeSheet)。单元格(YourCell)。调整大小(rSrc.Rows.Count ,rSrc.Columns.Count) rDst = rSrc.Value I have an Excel workbook, which using VBA code that opens another workbook, copies some data into the original, then closes the second workbook.When I close the second workbook (using Application.Close), I get a prompt for:Is there a command in VBA which will bypass this prompt? 解决方案 I can offer two optionsDirect copyBased on your description I'm guessing you are doing something like Set wb2 = Application.Workbooks.Open("YourFile.xls")wb2.Sheets("YourSheet").[<YourRange>].CopyThisWorkbook.Sheets("SomeSheet").Pastewb2.closeIf this is the case, you don't need to copy via the clipboard. This method copies from source to destination directly. No data in clipboard = no promptSet wb2 = Application.Workbooks.Open("YourFile.xls")wb2.Sheets("YourSheet").[<YourRange>].Copy ThisWorkbook.Sheets("SomeSheet").Cells(<YourCell")wb2.closeSuppress promptYou can prevent all alert pop-ups by settingApplication.DisplayAlerts = False[Edit]To copy values only: don't use copy/paste at allDim rSrc As RangeDim rDst As RangeSet rSrc = wb2.Sheets("YourSheet").Range("YourRange")Set rDst = ThisWorkbook.Sheets("SomeSheet").Cells("YourCell").Resize(rSrc.Rows.Count, rSrc.Columns.Count)rDst = rSrc.Value 这篇关于关闭工作簿中Excel VBA中的剪贴板提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-19 06:01