Change or grey out custom right click menu options depending on focus. I have procedures that run off normal right click (1 Viewer)

bignose2

Registered User.
Local time
Today, 21:28
Joined
May 2, 2010
Messages
219
Hi,

Just getting into custom menu's, They work well but would quite like to ideally grey out or hide menu options that should not be available depending on where the focus is.
I can of course test & stop if running but prefer its not obvious to use from the drop down menu itself.

CUrrently
Dim EPForm As Form

Dim NewMenu As Object
Dim NewClick As Object
On Error Resume Next
CommandBars("customsm").Delete
Set NewMenu = CommandBars.Add("customsm", 5, False, True)


NewMenu.Controls.Add 1, 19, , , True ' copy
NewMenu.Controls.Add 1, 22, , , True ' paste


Set NewClick = NewMenu.Controls.Add(1)
NewClick.begingroup = True
NewClick.Caption = "Copy Dates For Email"
NewClick.onaction = "=CopyDatesForEmail('DummyArg')"

Set NewClick = NewMenu.Controls.Add(1)
NewClick.Caption = "Change BOOKED Dates to above"
NewClick.onaction = "=ChangeDogsBookedDates('DummyArg')"

It is one or the other of my custom procedures I would like to hide

Thanks I/A
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:28
Joined
May 7, 2009
Messages
19,169
you can create Another custom shortcut menu Without
the Menu you want to exclude.

you can Toggle between shortcut menus Conditionally.
say you made another custom menu "customsm2"
you want this menu to be available whenever your
cursor is in "field1"(example) on the form.

private sub form_open(cancel as integer)
'use shortcut1
me.ShortcutMenuBar = "customsm"
end sub

'when the cursor is in "field1"
private sub field1_gotfocus()
'change shortcut to shortcut2
me.ShortcutMenuBar = "customsm2"
end ssub

'when you leave "field1"
private sub field1_lostfocus()
're-instate shortcut1
me.ShortcutMenuBar = "customsm"
end sub
 

Users who are viewing this thread

Top Bottom