简体   繁体   English

在Excel中禁用复制(Ctrl + C),粘贴(Ctrl + V),剪切(Ctrl + X)

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

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. 我在C#中开发了vsto模板,在其中,我为excel工作表中的许多字段添加了数据验证。如果用户复制粘贴内容,则这些验证规则将被覆盖并且不起作用。 how can i restrict user to copy,paste,cut.**Is there any **other way to overcome this problem? 我如何限制用户复制,粘贴,剪切。**是否有其他方法可以克服此问题?

Have you tried protecting the workbook ? 您是否尝试过保护工作簿? Two ways to do the same 两种相同的方法

1.) manually 1.) 手动

2.) programatically 2.)以编程方式

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM