Customise Right Click BUtton

chrisjames25

Registered User.
Local time
Today, 13:07
Joined
Dec 1, 2014
Messages
404
Hi

Im trying to create a cutom right click option in one of my forms.

I watched a youtube video and copied the code. He added 5 option to his right click but rather than type all out i wanted to check it worked with one first but it didnt work

Code:
Private Sub CreateSubFormShortcutMenu()
Dim MenuName As String
Dim CB As CommandBar
Dim CBB As commandbarbutton

MenuName = "vbaShortCutMenu"

On Error Resume Next
    Application.CommandBars(MenuName).Delete
On Error GoTo 0

Set CB = applications.CommandBars.Add(MenuName, msoBarPopup, False, False)
Set CBB = CB.Controls.Add(msocontrolbutton, 15948, , , True)
CBB.Caption = "Print..."


Set CB = Nothing
Set CBB = Nothing

End Sub

When it fires i get for Dim CB as command bar a compile error stating user-defined type not defined.

Any help on why code wrong or an explanation how to code it myself or better code would be greatly appreciated.

CHeers
 
You've a "s" to much in "applications.Comma..."
 

Users who are viewing this thread

Back
Top Bottom