Change Default PPT Addin Keystroke Accelerator

L

Legacy 298751

Guest
Hi,

I've created a PowerPoint addin that allows me to manipulate shapes using a new toolbar with buttons connected to various macros. When I install the addin, PowerPoint automatically assigns keystroke accelerators to the buttons I created on the new addin toolbar...[Alt, X, Y1]....[Alt, X, Y2]...etc. Is it possible to change these default accelerators to for example...[Alt, X, R, R]... using VBA such that when I update the addin code and re-install the addin on multiple computers, the accelerators will be whatever I define them as? The code I am using for my new toolbar (copied from a forum and tweaked for my purpose) is below and I am working in PowerPoint 2016. Just in case it isn't immediately obvious, I'm a complete noob so feel free to suggest improvements to the below if necessary.

Code:
[COLOR=blue]Sub[/COLOR] Auto_Open() 
    [COLOR=blue]Dim[/COLOR] oToolbar [COLOR=blue]As[/COLOR] CommandBar 
    [COLOR=blue]Dim[/COLOR] oButton [COLOR=blue]As[/COLOR] CommandBarButton 
    [COLOR=blue]Dim[/COLOR] MyToolbar [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR] 
     
     
    MyToolbar = "Shape Manipulator" 
     
     
    [COLOR=blue]On Error Resume Next[/COLOR] 
     
    [COLOR=blue]Set[/COLOR] oToolbar = CommandBars.Add(Name:=MyToolbar, _ 
    Position:=msoBarFloating, Temporary:=[COLOR=blue]True[/COLOR]) 
    [COLOR=blue]If[/COLOR] Err.Number <> 0 [COLOR=blue]Then[/COLOR] 
        Exit [COLOR=blue]Sub[/COLOR] 
    [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR] 
     
     
    [COLOR=blue]On Error Goto[/COLOR] ErrorHandler 
     
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
        .DescriptionText = "Pick Up Shape Attributes" 
         
        .Caption = "Pick Up Attributes" 
         
        .OnAction = "CopySizeAndPosition" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 351 
         
         
    [COLOR=blue]End With[/COLOR] 
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Paste Shape Attributes" 
         
        .Caption = "Paste Attributes" 
         
        .OnAction = "PasteSizeAndPosition" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 352 
         
    [COLOR=blue]End With[/COLOR] 
     
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Stretch Left" 
         
        .Caption = "Stretch Left" 
         
        .OnAction = "StretchLeft" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 132 
         
    [COLOR=blue]End With[/COLOR] 
     
     
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Stretch Right" 
         
        .Caption = "Stretch Right" 
         
        .OnAction = "StretchRight" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 133 
         
    [COLOR=blue]End With[/COLOR] 
     
     
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Stretch Up" 
         
        .Caption = "Stretch Up" 
         
        .OnAction = "StretchUp" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 134 
         
    [COLOR=blue]End With[/COLOR] 
     
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Stretch Down" 
         
        .Caption = "Stretch Down" 
         
        .OnAction = "StretchDown" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 135 
         
    [COLOR=blue]End With[/COLOR] 
     
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Stretch Vertically" 
         
        .Caption = "Stretch Vertically" 
         
        .OnAction = "StretchVertically" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 1147 
         
    [COLOR=blue]End With[/COLOR] 
     
    [COLOR=blue]Set[/COLOR] oButton = oToolbar.Controls.Add(Type:=msoControlButton) 
     
     
    [COLOR=blue]With[/COLOR] oButton 
         
         
        .DescriptionText = "Stretch Horizontally" 
         
        .Caption = "Stretch Horizontally" 
         
        .OnAction = "StretchHorizontally" 
         
        .Style = msoButtonIconAndCaptionBelow 
         
        .FaceId = 1146 
         
    [COLOR=blue]End With[/COLOR] 
     
    oToolbar.Top = 150 
    oToolbar.Left = 150 
    oToolbar.Visible = [COLOR=blue]True[/COLOR] 
     
     
NormalExit: 
    Exit [COLOR=blue]Sub[/COLOR] 
     
     
ErrorHandler: 
    MsgBox Err.Number & vbCrLf & Err.Description 
Resume NormalExit: 
[COLOR=blue]End Sub[/COLOR]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top