Word 2003: Prevent "Send To" and "Save as web page" from the file menu
I have written the following code to disable the "Send To" and "Save as webpage".
It works....But it is linked up to the "Document_Open" event and the users may prevent that event by holding down the SHIFT key.
I have thought of three ways of making sure that my script runs.
1) Is it possible to call my code from an Idle event?
- From what I seen this is not possible
2) Is it possible to capture the event when the user clicks on "File" (but before selecting the submenu below file)?
- Doubt it
3) Capture each choice the user makes from the menues and check if it is legal after the choice is made. So if he/she disables the "document_open" macros he/she is still not able to click the menu options I don't want the user to click. What is the event that runs after a menu option has been selected?
- This might be the "solution".
Finally this is the code so far:
VB Code:
Public Sub ToggleSendTo(enableFlag As Boolean)
' Disable/enable Save as web page
' Disable/enable Send to
Const saveAsWebPage = 3823
Const sendTo = 30095
Dim n As Integer
For n = 1 To Application.CommandBars("File").Controls.Count
If Application.CommandBars("File").Controls(n).ID = saveAsWebPage Then
Application.CommandBars("File").Controls(n).Enabled = enableFlag
ElseIf Application.CommandBars("File").Controls(n).ID = sendTo Then
Application.CommandBars("File").Controls(n).Enabled = enableFlag
End If
Next n
End Sub