Having macro add PasteSpecial Values button to toolbar
Thanks! I had figured out the Count property, but what was holding me back
was not knowing about the ID property. This is what I simplified it to:
Sub AddPasteValuesButton()
' adds PasteSpecial Values button to Standard toolbar
Dim i As Integer
' if no Standard toolbar we do nothing
If Not Application.CommandBars("Standard").Visible Then Exit Sub
' check for existing PasteSpecial Values button
For i = 1 To Application.CommandBars("Standard").Controls.Count
If Application.CommandBars("Standard").Controls(i).ID = 370 Then Exit Sub
Next i
' check for Copy button (so we can paste to its right)
For i = 1 To Application.CommandBars("Standard").Controls.Count
If Application.CommandBars("Standard").Controls(i).ID = 19 Then
Application.CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=370, Befo=i + 1
Exit Sub
End If
Next i
' no Copy Button on the toolbar, so place PasteSpecial Values somewhere
Application.CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=370, Befo=10
End Sub
|