Re: Adding Customised Buttons to a toolbar

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Bob,

I tried your code but when I try to run it it comes up with a run-time error
'5', Invalid Procedure Call or Argument. I am using MS Excel 2002.

Can you advise what might be causing this?

Thanks,
Geoff.

"Bob Phillips" wrote:

Build it dynamically

Private Sub Workbook_BeforeClose(Cancel As Boolean)

With Application.CommandBars("Formating")

On Error Resume Next
.Controls("myButton1").Delete
.Controls("myButton2").Delete
.Controls("myButton3").Delete
On Error GoTo 0

End With

End Sub

Private Sub Workbook_Open()

With Application.CommandBars("Formating")

On Error Resume Next
.Controls("myButton1").Delete
.Controls("myButton2").Delete
.Controls("myButton3").Delete
On Error GoTo 0

With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "myButton1"
.Style = msoButtonIcon
.FaceId = 29
.OnAction = "myMacro1"
End With

With .Controls.Add(Type:=msoControlButton, temporary:=True)
.Caption = "myButton2"
.Style = msoButtonIcon
.FaceId = 30
.OnAction = "myMacro2"
End With

With .Controls.Add(Type:=msoControlButton, temporary:=True)
.Caption = "myButton3"
.Style = msoButtonIcon
.FaceId = 31
.OnAction = "myMacro3"
End With

End With

End Sub


This is workbook event code.
To input this code, right click on the Excel icon on the work***
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"GLT" <GLT@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5118041E-6D61-483E-A2C5-F6C3E8D22447@xxxxxxxxxxxxxxxx
Hi,

I have an excel document in which I added three buttons to a toolbar which
are assigned to three different Macro's.

I then email a copy of the work*** to my colleagues and when they open
the
file, the buttons that I originally created no longer appear where I put
them.

How do I ensure that any customization that I do of an Excel work***
stays
permanently on the work*** when it's emailed to others?

Thanks...




.


Quantcast