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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:34:55  来源:igfitidea点击:

Disable copy(ctrl+c), paste(ctrl+v),cut(ctrl+x) in excel

c#excel-vbavstovbaexcel

提问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

Have you tried protecting the workbook ? Two ways to do the same

您是否尝试过保护工作簿?两种方法做同样的事情

1.)manually

1.)手动

2.)programatically

2.) 以编程方式

回答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);