Quantcast
Channel: Word for Developers forum
Viewing all articles
Browse latest Browse all 4350

Issue when Disabling Context Menu and shortcuts in Word Documents.

$
0
0

I need to protect a word document from cut, copy , paste , paste Special, save and save Shortcuts.

So far I have been able to achieve my goals by using the code below:

Imports Microsoft.Office.InteropDim WrdApp As Word.ApplicationDim WrdDocs As Word.DocumentsDim WrdDoc As Word.DocumentDim cb As CommandBarDim cbCtl As CommandBarControlForEach cb In WrdDoc.CommandBarsIf cb.Name <>"ClipBoard"Then
                cbCtl = cb.FindControl(,21,,,True)'(Cut Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =False

                cbCtl = cb.FindControl(,19,,,True)'(Copy Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =False

                cbCtl = cb.FindControl(,22,,,True)'(paste Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =False

                cbCtl = cb.FindControl(,755,,,True)'(Paste Special Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =FalseEndIfNext
   WrdApp.FindKey(WrdApp.BuildKeyCode(Word.WdKey.wdKeyControl, word.WdKey.wdKeyS)).Disable()
     WrdApp.FindKey(WrdApp.BuildKeyCode(Word.WdKey.wdKeyControl),Word.WdKey.wdKeyC).Disable()
 WrdApp.FindKey(WrdApp.BuildKeyCode(Word.WdKey.wdKeyControl), Word.WdKey.wdKeyX).Disable()

I have just found out that the latter code, works at the level of the entire word application and not at the level of each document; and that's my problem.

I need to disable the context menu and save options per documents ; user can save and copy from the first document, but could not for another document.

Is there a turn-around to this issue?

Your help is appreciated.

Best Regards.


Viewing all articles
Browse latest Browse all 4350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>