Okay, delved a little more (making some decent progress today). What I've done is decided that I wanted a little more interactivity between myself and Outlook, and I felt the best way to do that was to go the custom menu route. So this code will give you a custom menu called 'Admin' after your Help menu, which has two options, Enable Exit and Disable Exit.
This requires changing some code in your ThisOutlookSession module and creating 2 new Standard Modules.
In ThisOutlookSession paste:
<font face=Tahoma New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Application_Startup()
<SPAN style="color:#00007F">Call</SPAN> DisableExit
<SPAN style="color:#00007F">Call</SPAN> CreateMenu
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
In module Mod_Menu (just my naming convention:
<font face=Tahoma New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>
<SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Const</SPAN> APP_NAME <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "Admin"
<SPAN style="color:#00007F">Sub</SPAN> CreateMenu()
<SPAN style="color:#00007F">Dim</SPAN> CB <SPAN style="color:#00007F">As</SPAN> CommandBar
<SPAN style="color:#00007F">Dim</SPAN> Menu <SPAN style="color:#00007F">As</SPAN> CommandBarPopup
<SPAN style="color:#00007F">Dim</SPAN> Item <SPAN style="color:#00007F">As</SPAN> CommandBarButton
<SPAN style="color:#00007F">Dim</SPAN> Pos <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>
<SPAN style="color:#00007F">Call</SPAN> DeleteMenu
<SPAN style="color:#00007F">Set</SPAN> CB = Application.ActiveExplorer.CommandBars.Item("Menu Bar")
Pos = CB.Controls.Count + 1
<SPAN style="color:#007F00">'Main Menu</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Menu = CB.Controls.Add(Type:=msoControlPopup, before:=Pos)
Menu.Caption = APP_NAME
Menu.BeginGroup = <SPAN style="color:#00007F">True</SPAN>
<SPAN style="color:#007F00">'Menu Items</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Item = Menu.Controls.Add(Type:=msoControlButton)
<SPAN style="color:#00007F">With</SPAN> Item
.Caption = "&Enable Exit"
.FaceId = 1 <SPAN style="color:#007F00">'set as desired</SPAN>
.OnAction = "EnableExit"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Item = Menu.Controls.Add(Type:=msoControlButton)
<SPAN style="color:#00007F">With</SPAN> Item
.Caption = "&Disable Exit"
.FaceId = 1 <SPAN style="color:#007F00">'set as desired</SPAN>
.OnAction = "DisableExit"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Item = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> Menu = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> CB = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">Sub</SPAN> DeleteMenu()
<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
Application.ActiveExplorer.CommandBars.Item("Menu Bar").Controls(APP_NAME).Delete
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
In module Mod_Routines (just my naming convention:
<font face=Tahoma New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN>
<SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Const</SPAN> PWD <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "admin"
<SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Sub</SPAN> DisableExit()
<SPAN style="color:#00007F">Dim</SPAN> tmp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
tmp = InputBox("Enter Password:", "Password")
<SPAN style="color:#00007F">If</SPAN> Len(tmp) = 0 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">If</SPAN> tmp <> PWD <SPAN style="color:#00007F">Then</SPAN>
MsgBox "Sorry! Wrong password. Try again.", vbInformation, "ERROR!"
<SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
Application.ActiveExplorer.CommandBars.Item("Menu Bar" _
).Controls.Item("&File").Controls.Item("E&xit").Enabled = <SPAN style="color:#00007F">False</SPAN>
MsgBox "File | Exit is now disabled!", vbExclamation
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Sub</SPAN> EnableExit()
<SPAN style="color:#00007F">Dim</SPAN> tmp <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
tmp = InputBox("Enter Password:", "Password")
<SPAN style="color:#00007F">If</SPAN> Len(tmp) = 0 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">If</SPAN> tmp <> PWD <SPAN style="color:#00007F">Then</SPAN>
MsgBox "Sorry! Wrong password. Try again.", vbInformation, "ERROR!"
<SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
Application.ActiveExplorer.CommandBars.Item("Menu Bar" _
).Controls.Item("&File").Controls.Item("E&xit").Enabled = <SPAN style="color:#00007F">True</SPAN>
MsgBox "File | Exit is now enabled!", vbExclamation
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
Works great for me in OL 2003, do not have any previous versions here for me to test on. I'm working on that API call to disable the X button - still not sure if that can be done or not though.
Hope this helps you Zoso.