I disable Full Menus, Default Shortcut Menus, and Navigation Pane.
Here is how I set up custom ribbon http://forums.aspfree.com/microsoft-...at-303789.html
My deployed db code is a bit different from that example. This code is in a module called Customization. I also have code to disable the application X close button.
Code:
Option Compare Database
Option Explicit
'API function to disable the X Close button is for 32-bit machine
'If Lab gets 64-bit machines use the Unload event of Menu form to capture Access X close and Office button Exit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal wRevert As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Sub OnRibbonLoad(ribbon As IRibbonUI)
' Callbackname in XML File "onLoad"
DoCmd.OpenForm "Login"
End Sub
Public Sub RibbonButtonClick(CONTROL As IRibbonControl)
Select Case CONTROL.ID
Case "btnDates"
DoCmd.OpenForm "ConcreteBreakDates"
Case Else
MsgBox "Button """ & CONTROL.ID & """ click", vbInformation, "Quick Access Toolbar"
End Select
End Sub
Public Sub SetAccessXCloseButton(pfEnabled As Boolean)
' Comments: Control the Access close button.
' Disabling it forces the user to exit within the application
' In : pfEnabled TRUE enables the close button, FALSE disabled it
' Owner : Copyright (c) 2008-2009 from FMS, Inc.
' Source : Total Visual SourceBook
' Usage : Permission granted to subscribers of the FMS Newsletter
On Error Resume Next
Const clngMF_ByCommand As Long = &H0&
Const clngMF_Grayed As Long = &H1&
Const clngSC_Close As Long = &HF060&
Dim lngWindow As Long
Dim lngMenu As Long
Dim lngFlags As Long
lngWindow = Application.hWndAccessApp
lngMenu = GetSystemMenu(lngWindow, 0)
If pfEnabled Then
lngFlags = clngMF_ByCommand And Not clngMF_Grayed
Else
lngFlags = clngMF_ByCommand Or clngMF_Grayed
End If
Call EnableMenuItem(lngMenu, clngSC_Close, lngFlags)
End Sub
Here is the HTML in USysRibbons table.
The first one is for my custom default ribbon and is set in the project Ribbon Name property. The second is for reports and is set in each report RibbonName property.
Code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad" >
<commands>
<command idMso="Help" enabled="false"/>
</commands>
<ribbon startFromScratch="true">
<officeMenu>
<button idMso="FileOpenDatabase" visible="false"/>
<button idMso="FileNewDatabase" visible="false"/>
<button idMso="FileCloseDatabase" visible="false"/>
</officeMenu>
<qat>
<documentControls>
<button idMso="DataRefreshAll"/>
</documentControls>
</qat>
</ribbon>
</customUI>
________________________
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<commands>
<command idMso="Help" enabled="false"/>
</commands>
<ribbon startFromScratch="true">
<officeMenu>
<button idMso="FileOpenDatabase" visible="false"/>
<button idMso="FileNewDatabase" visible="false"/>
<button idMso="FileCloseDatabase" visible="false"/>
</officeMenu>
<qat>
<documentControls>
<button idMso="PrintDialogAccess"/>
</documentControls>
</qat>
</ribbon>
</customUI>
Here is code behind my MainMenu form that calls the function to disable the X button:
Code:
Private Sub Form_Open(Cancel As Integer)
Call SetAccessXCloseButton(False)
End Sub