在Excel中禁用复制(ctrl + c),粘贴(ctrl + v),剪切(ctrl + x) [英] Disable copy(ctrl+c), paste(ctrl+v),cut(ctrl+x) in excel

查看:348
本文介绍了在Excel中禁用复制(ctrl + c),粘贴(ctrl + v),剪切(ctrl + x)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C#开发了vsto模板,在其中,我为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. how can i restrict user to copy,paste,cut.**Is there any **other way to overcome this problem?

推荐答案

以下代码应拦截Ctrl + V并有效地将其禁用

Following code should intercept Ctrl+V and effectively disable it

1.要禁用粘贴选项(ctrl + v)

1.To disable the Paste Option(ctrl + v )

Application.OnKey("^v", "");

2.再次启用粘贴选项(ctrl + v)

2.To enable the Paste Option(ctrl + v ) again

Application.OnKey("^v", Type.Missing);

这篇关于在Excel中禁用复制(ctrl + c),粘贴(ctrl + v),剪切(ctrl + x)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆