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

烈酒焚心 提交于 2020-06-17 08:23:07

问题


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?


回答1:


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

1.)manually

2.)programatically




回答2:


Following code should intercept Ctrl+V and effectively disable it

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

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

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

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


来源:https://stackoverflow.com/questions/4825664/disable-copyctrlc-pastectrlv-cutctrlx-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!