vba 在excel中禁用复制(ctrl+c)、粘贴(ctrl+v)、剪切(ctrl+x)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4825664/
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
Disable copy(ctrl+c), paste(ctrl+v),cut(ctrl+x) in excel
提问by Smack
I have developed the vsto template in C# in which,i have added data validation for many fields in the excel sheet.If the user copy paste the content, those validations rules are overwrites and does not work. how can i restrict user to copy,paste,cut.**Is there any **other way to overcome this problem?
我在 C# 中开发了 vsto 模板,其中,我为 Excel 表中的许多字段添加了数据验证。如果用户复制粘贴内容,这些验证规则将被覆盖并且不起作用。我如何限制用户复制、粘贴、剪切。**有没有其他方法可以解决这个问题?
回答by Clyde Lobo
回答by Sangram Nandkhile
Following code should intercept Ctrl+V and effectively disable it
以下代码应拦截 Ctrl+V 并有效禁用它
1.To disable the Paste Option(ctrl + v )
1.禁用粘贴选项(ctrl + v)
Application.OnKey("^v", "");
2.To enable the Paste Option(ctrl + v ) again
2.再次启用粘贴选项(ctrl + v)
Application.OnKey("^v", Type.Missing);