Right-Click event of Shape

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,256
This code captures the action when the user checks the checkbox on Sheet1:

Code:
Option Explicit



' Worksheet module


Dim CheckBoxesColl As Collection


Private Sub Worksheet_Activate()


Dim CheckBoxHandler As ClsCheckBoxEvent

Dim MyShp As Shape


Set CheckBoxesColl = New Collection


For Each MyShp In Me.Shapes

    If MyShp.Type = msoOLEControlObject Then
    
        If TypeOf MyShp.OLEFormat.Object.Object Is MSForms.CheckBox Then

            Set CheckBoxHandler = New ClsCheckBoxEvent

            Set CheckBoxHandler.CheckGroup = MyShp.OLEFormat.Object.Object

            CheckBoxesColl.Add CheckBoxHandler

       End If

    End If

Next MyShp

End Sub


This is in ClsCheckBoxEvent:

Code:
Option Explicit


Public WithEvents CheckGroup As MSForms.CheckBox


Private Sub CheckGroup_Click()


    ' Code to act when the checkboxes are checked / unchecked


End Sub

How can I adapt it to capture the right-clicking of a shape?

Thanks
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,503
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Re: Right-Ccick event of Shape

You can't do it in the Click event, you need to use the MouseDown or MouseUp events and check the Button parameter.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,954
Messages
5,525,876
Members
409,668
Latest member
mitunsLax

This Week's Hot Topics

Top