Consulting

Results 1 to 6 of 6

Thread: To Click or Ctrl + Click?

  1. #1
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location

    To Click or Ctrl + Click?

    Hey people,

    I guess this is a general question, but I put it in the PPT section because that's what I want to apply the answer to (in my case).

    Is there a way to set different code to run depending if the user Clicks or (Ctrl + Clicks) or (Shift + Clicks) a macro button?
    Office 2010, Windows 7
    goal: to learn the most efficient way

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    Try this in slide show mode and click the [i] button with various combanations of shifts

    Paul

  3. #3
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location
    Thanks Paul,

    I should have been more clear. I want to apply this test to a macro button on a toolbar I created via code. Can I apply the same kind of logic to something like that?

    I looked at that code and it almost made my brain explode.
    Office 2010, Windows 7
    goal: to learn the most efficient way

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    Well .....

    This is some code I use to determine is the Shift key was down when I click a control / command button. Maybe you could adopt it to fit your needs.

    It still uses the IsShiftKeyDown () sub from the PPT file, and returns the Control (object), the control's caption, and a boolean if the shift was down when clicked

    One thing -- if you have command bar with a menu and you click on a control on that menu, you need to have the shift down when you click on the command bar's menu. Not sure why, but also never bothered to investigate.


    Sub ButtonClicked(ByRef ctlClicked As CommandBarControl, _
        ByRef sCaption As String, _
            ByRef bShifted As Boolean)
        Set ctlClicked = Application.CommandBars.ActionControl
    If ctlClicked Is Nothing Then
        sCaption = ""
        bShifted = False
        Else
        sCaption = ctlClicked.Caption
        bShifted = IsShiftKeyDown
        End If
    End Sub
    Last edited by Aussiebear; 04-28-2023 at 08:15 PM. Reason: Adjusted the code tags

  5. #5
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location
    Thanks Paul!

    I'm sure this will help. I'm excited to try it out.
    Office 2010, Windows 7
    goal: to learn the most efficient way

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    Let me know how it worked

    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •