Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Menubar.........

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I want disable some Menubar on Toolbar. How to do this?
Example: Edit\Paste ...(Default)
 
In the main database window click on tools -- then startup -- I think you can disable certain menu features within there --

If you want to undo the changes -- when the database next loads up, right click on the database window to get back into the startup options screen...

:eek:)

Hj
 
All menu items have a unique ID.

This code will give you the ID for a given menu option:
e.g. FindMenuID "&Paste" will display the ID 22.

Sub FindMenuItemID(strCaption As String)

Dim cb As CommandBar
Dim cbc As CommandBarControl

For Each cb In CommandBars
For Each cbc In cb.Controls
If cbc.Caption = strCaption Then
MsgBox "The ID for '" & strCaption & "' is " & cbc.ID
Exit Sub
End If
Next
Next

MsgBox "Cannot find control with caption of '" & strCaption & "'"

End Sub

Once you know the ID, this code will enable or disable ALL the controls with the same ID.
e.g. 'EnableControls 22,false' will disable all paste commands

Sub EnableControls(lngID As Long, blnEnable As Boolean)

Dim cbcs As CommandBarControls
Dim lngIndex As Long

Set cbcs = Application.CommandBars.FindControls(ID:=lngID)

If cbcs Is Nothing Then Exit Sub

For lngIndex = 1 To cbcs.Count
cbcs(lngIndex).Enabled = blnEnable
Next

End Sub

For this code to work you must set a Reference to Microsoft Office object library.

HTH.

M *<|:)
 
If you're doing this from Visual Basic, you can use the CommandBars object to turn on and off any command you want. Use the following to turn off the Edit/Paste function on the default menubar:
Code:
CommandBars(&quot;Database&quot;).Controls(2).CommandBar.Controls(5).Enabled = False
Change the numbers to match the control you want to disable. Start counting from 1. Let me know if you have any more questions about this method.

--Ryan
 
It is sometimes easier to make you own custom menubar and just put the stuff on it that you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top