Solved

EXCEL VBA - RIGHT MOUSE CLICK MENU ACTIVATION

Posted on 2011-02-18
3
870 Views
Last Modified: 2012-05-11
hi i would like all the code for EXCEL VBA (office 2003) - Windows 2003 to create a right mouse click menu activation event to add to my automated excel spreadsheet. I want to add this so that i can add selections to this menu that will activate other functions.
I have posted a sample right mouse menu click screenshot for your reference.
right-mouse-click-menu-activatio.jpg
0
Comment
Question by:FrankSasso
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 500 total points
ID: 34929835
Excel already has a right mouse click menu on the worksheet. What you can do is add options to that menu.
Here's a sample code to add 3 more options that will open 3 userforms.

jppinto
Sub AlterWorkSheetPopup2()
    Dim oCtrl As Object
    Dim arr1 As Variant, arr2 As Variant
    arr1 = Array("Click Here", "Click Now", "Click Next") 'Button names
    arr2 = Array("UsrfrmShow", "UsrfrmShow", "UsrfrmShow") 'Macro Names
    With Application.CommandBars("Cell")
        'Add a new menu
        For i = 0 To UBound(arr1)
            With .Controls.Add(msoControlButton)
                .Caption = arr1(i)
                .OnAction = arr2(i)
            End With
        Next i
    End With
End Sub

Open in new window

0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 500 total points
ID: 34929847
This sample code add options to the right click menu that will fire macros.

jppinto
Sub AddItemsToRightClickMenu()
Dim myBar As Object, newItem As Object

Set newItem = CommandBars("Cell").Controls.Add(Type:=msoControlButton)
With newItem
    .BeginGroup = True
    .Caption = "My Macro Button 1"
    .FaceId = 49
    .OnAction = "PERSONAL.XLS!MyMacro1"
End With

Set newItem = CommandBars("Cell").Controls.Add(Type:=msoControlButton)
With newItem
    .Caption = "My Macro Button 2"
    .FaceId = 50
    .OnAction = "PERSONAL.XLS!MyMacro2"
End With

' Add more items here...

End Sub

Open in new window

0
 

Author Closing Comment

by:FrankSasso
ID: 34930030
thankyou
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now