You can disable or delete the context menu item in MS Word or Excel by VBA programming.
Word:
OA1.CreateNew “Word.Document”
Set objWord = OA1.ActiveDocument
objWord.Application.CommandBars(“Text”).Controls(“Cu&t”).Enabled = False
objWord.Application.CommandBars(“Text”).Controls(“&Copy”).Enabled = False
objWord.Application.CommandBars(“Text”).Controls(“&Paste”).Enabled = False
‘delete item directly
‘objWord.Application.CommandBars(“Text”).Controls(1).Delete
‘objWord.Application.CommandBars(“Text”).Controls(2).Delete ….
Excel
OA1.Open “c:\text.xls”
Set objExcel = OA1.ActiveDocument
objExcel .Application.CommandBars(“Cell”).Controls(“Cu&t”).Enabled = False
objExcel .Application.CommandBars(“Cell”).Controls(“&Copy”).Enabled = False
objExcel .Application.CommandBars(“Cell”).Controls(“&Paste”).Enabled = False
‘delete item directly
‘objExcel .Application.CommandBars(“Cell”).Controls(1).Delete
‘objExcel .Application.CommandBars(“Cell”).Controls(2).Delete ….
4 Responses to “Disable Popup Menu in MS Office”
Leave a Reply
You must be logged in to post a comment.
July 7th, 2008 at 1:31 pm
Disable the Print command:
objExcel.Application.CommandBars(“menu Bar”).Controls(“&File”).Controls(“&Print…”).Enabled = False
July 7th, 2008 at 1:32 pm
How to know the Caption of the menu item in MS Office?
Sub ListAllMenuItems()
For i = 1 To CommandBars.Count
Selection.TypeText i & “:” & CommandBars(i).Name
Selection.TypeParagraph
For a = 1 To CommandBars(i).Controls.Count
Selection.TypeText ” ” & a & “:” & CommandBars(i).Controls(a).Caption
Selection.TypeParagraph
Next
Next
End Sub
July 7th, 2008 at 1:34 pm
Change the position of the toolbar
Sub AdjustToolbarPos()
objExcel.Application.CommandBars(“clipboard”).Visible = True
objExcel.Application.CommandBars(“clipboard”).Position = msoBarTop
objExcel.Application.CommandBars(“clipboard”).RowIndex = CommandBars(“standard”).RowIndex
objExcel.Application.CommandBars(“clipboard”).Left = CommandBars(“standard”).Left + CommandBars(“standard”).Width
End Sub
November 9th, 2008 at 1:50 am
How do I disable the popup menu in the slide show? or disable copy / print and edit option?
It is the menu number 45; controls from 1 to 8 , that disable all options of the menu displayed with the right click
objPPT.application.CommandBars(45).controls(1).enabled=false; (advance option , first of the menu)
..
objPPT.application.CommandBars(45).controls(8).enabled=false;