Programming Office Commandbars - how to disable shortcut menus

This is one of the FAQs about Office Commandbars. For some reason, you may want to suppress the shortcut menus brought up by right-clicking the content of an Office document. This is an example of how to disable them in Word:

  
CustomizationContext = ActiveDocument
Dim bar As CommandBar
For Each bar In CommandBars
    If bar.Type = msoBarTypePopup Then
        bar.Enabled = False
    End If
Next

With little modification, you should be able to do the same thing in Excel, PowerPoint and other Office applications that have the Office Commandbars collection.