ok, well here's the routine that creates the toolbar:
Public Sub AddToolBar()
On Error Resume Next
Dim I As Integer
Dim J As Integer
Dim sToolBar As String
On Error Resume Next
sToolBar = Application.CommandBars(YOUR_TOOLBAR_NAME).Name
If Err.Number <> 0 Then
Application.CommandBars.Add YOUR_TOOLBAR_NAME, , , True
ReadSettingIni Application.CommandBars(YOUR_TOOLBAR_NAME) '<- this line
End If
Application.CommandBars(YOUR_TOOLBAR_NAME).Visible = True
I = Application.CommandBars(YOUR_TOOLBAR_NAME).Controls.Count
For J = I To 1 Step -1
Application.CommandBars(YOUR_TOOLBAR_NAME).Controls(J).Delete
Next
On Error GoTo 0
If MyButton Is Nothing Then
Set MyButton = Application.CommandBars(YOUR_TOOLBAR_NAME).Controls.Add(1)
End If
With MyButton
.Caption = "Resize: "
.Style = msoButtonCaption 'caption only
.Tag = "height"
.Width = 50
.Visible = True
End With
If MyButton1 Is Nothing Then
Set MyButton1 = Application.CommandBars(YOUR_TOOLBAR_NAME).Controls.Add(2) 'ControlEdit (textbox)
End If
With MyButton1
.Width = 50
.Visible = True
End With
If MyButton2 Is Nothing Then
Set MyButton2 = Application.CommandBars(YOUR_TOOLBAR_NAME).Controls.Add(1)
End If
With MyButton2
.FaceId = 541 'height icon
.Style = msoButtonIcon 'icon only
.Tag = "Height"
.OnAction = "myControlRoutine"
.TooltipText = "Height"
.Width = 10
.Visible = True
End With
If MyButton3 Is Nothing Then
Set MyButton3 = Application.CommandBars(YOUR_TOOLBAR_NAME).Controls.Add(1)
End If
With MyButton3
.Caption = "Width"
.FaceId = 542 'width icon
.Style = msoButtonIcon 'icon only
.Tag = "Width"
.OnAction = "myControlRoutine"
.TooltipText = "Width"
.Width = 10
.Visible = True
End With
End Sub
and this is the routine that's activated when a button is pressed:
Sub myControlRoutine()
Dim mySlide As Long
Dim shp As Shape
Dim newWidth As Single
Dim newHeight As Single
Dim newShp As ShapeRange
Dim num As Long
Dim I As Long
Dim strVal As Variant
Dim ctrlEdit As CommandBarControl
Set ctrlEdit = CommandBars(YOUR_TOOLBAR_NAME).FindControl(Type:=msoControlEdit)
If Not ctrlEdit Is Nothing Then
If ctrlEdit.Text <> "" Then
myVal = ctrlEdit.Text
strVal = myVal
If IsNumeric(strVal) Then
'different action depending on which button was clicked
Select Case CommandBars.ActionControl.Tag
Case "Height"
Call changeHeight
Case "Width"
Call changeWidth
End Select
'MsgBox "Do " & CommandBars.ActionControl.Caption & " with value: " & myVal
Else
MsgBox "Values must be numeric."
ctrlEdit.Text = ""
End If
Else
MsgBox "Please enter a value to resize with."
End If
End If
End Sub
and these are the routines the buttons do:
Sub changeHeight()
Dim colTemp As New Collection
Dim shp As Shape
Dim I As Long
With ActiveWindow.Selection
If .Type = ppSelectionShapes Then
'add all selected shapes to new collection
For Each shp In .ShapeRange
colTemp.Add shp
Next shp
End If
End With
'resize shapes
For I = 1 To colTemp.Count
With ActiveWindow.Selection.ShapeRange
.LockAspectRatio = msoTrue
.Height = myVal * 72
End With
Next
End Sub
Sub changeWidth()
Dim colTemp As New Collection
Dim shp As Shape
Dim I As Long
With ActiveWindow.Selection
If .Type = ppSelectionShapes Then
'add all selected shapes to new collection
For Each shp In .ShapeRange
colTemp.Add shp
Next shp
End If
End With
'resize shapes
For I = 1 To colTemp.Count
With ActiveWindow.Selection.ShapeRange
.LockAspectRatio = msoTrue
.Width = myVal * 72
End With
Next
End Sub
I presume I don't need to post any other code that's needed for the addin (auto-open, auto-close, etc)