vba Excel中Application.CutCopyMode属性的作用到底是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17607412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What exactly is the function of Application.CutCopyMode property in Excel
提问by Saikat
Well first of all I found couple of answers while googling but most of the forums are blocked in my Office Network
hence asking this question here! One more intention is to get an answer in plain English :P
首先,我在谷歌搜索时找到了几个答案,但大多数论坛都被我屏蔽了,Office Network
因此在这里问这个问题!还有一个目的是用简单的英语得到答案:P
I understand if we set Application.CutCopyMode = False
then the Copied/Cut results will be vanished (i.e. memory will be cleared) but when should we use this and when not to use this? Can anyone please help?
我知道如果我们设置,Application.CutCopyMode = False
那么复制/剪切结果将消失(即内存将被清除)但是我们什么时候应该使用它,什么时候不使用它?有人可以帮忙吗?
回答by
By referring this(http://www.excelforum.com/excel-programming-vba-macros/867665-application-cutcopymode-false.html) link the answer is as below:
通过参考这个(http://www.excelforum.com/excel-programming-vba-macros/867665-application-cutcopymode-false.html)链接,答案如下:
Application.CutCopyMode=False
is seen in macro recorder-generated code when you do a copy/cut cells and paste . The macro recorder does the copy/cut and paste in separate statements and uses the clipboard as an intermediate buffer. I think Application.CutCopyMode = False
clears the clipboard. Without that line you will get the warning 'There is a large amount of information on the Clipboard....'
when you close the workbook with a large amount of data on the clipboard.
Application.CutCopyMode=False
当您执行复制/剪切单元格并粘贴 . 宏记录器在单独的语句中进行复制/剪切和粘贴,并将剪贴板用作中间缓冲区。我认为Application.CutCopyMode = False
清除剪贴板。如果没有该行,There is a large amount of information on the Clipboard....'
当您关闭剪贴板上有大量数据的工作簿时,您将收到警告 ' 。
With optimised VBA code you can usually do the copy/cut and paste operations in one statement, so the clipboard isn't used and Application.CutCopyMode = False
isn't needed and you won't get the warning.
使用优化的 VBA 代码,您通常可以在一个语句中执行复制/剪切和粘贴操作,因此不使用Application.CutCopyMode = False
也不需要剪贴板,您也不会收到警告。
回答by Osama
Normally, When you copy a cell you will find the below statement written down in the status bar (in the bottom of your sheet)
通常,当您复制单元格时,您会在状态栏中(在您的工作表底部)找到以下语句
"Select destination and Press Enter or Choose Paste"
“选择目的地并按 Enter 或选择粘贴”
Then you press whether Enter or choose paste to paste the value of the cell.
然后按 Enter 或选择粘贴来粘贴单元格的值。
If you didn't press Esc afterwards you will be able to paste the value of the cell several times
如果您之后没有按 Esc,您将能够多次粘贴单元格的值
Application.CutCopyMode = Falsedoes the same like the Esc button, if you removed it from your code you will find that you are able to paste the cell value several times again.
Application.CutCopyMode = False与 Esc 按钮的作用相同,如果您从代码中删除它,您会发现您可以再次多次粘贴单元格值。
And if you closed the Excel without pressing Esc you will get the warning 'There is a large amount of information on the Clipboard....'
如果您在不按 Esc 的情况下关闭 Excel,您将收到警告“剪贴板上有大量信息......”
回答by George Birbilis
There is a good explanation at https://stackoverflow.com/a/33833319/903783
https://stackoverflow.com/a/33833319/903783有很好的解释
The values expected seem to be xlCopy and xlCut according to xlCutCopyMode enumeration (https://msdn.microsoft.com/en-us/VBA/Excel-VBA/articles/xlcutcopymode-enumeration-excel), but the 0 value (this is what False equals to in VBA) seems to be useful to clear Excel data put on the Clipboard.
根据 xlCutCopyMode 枚举(https://msdn.microsoft.com/en-us/VBA/Excel-VBA/articles/xlcutcopymode-enumeration-excel),预期值似乎是 xlCopy 和 xlCut ,但是 0 值(这是VBA 中 False 等于什么)似乎对清除剪贴板上的 Excel 数据很有用。