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.
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]