Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
GLT
 
Posts: n/a
Default Adding Customised Buttons to a toolbar

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 worksheet 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 worksheet stays
permanently on the worksheet when it's emailed to others?

Thanks...

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Adding Customised Buttons to a toolbar

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 worksheet
(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" wrote in message
...
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 worksheet 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 worksheet

stays
permanently on the worksheet when it's emailed to others?

Thanks...



  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Adding Customised Buttons to a toolbar

I think the easiest way to avoid this problem is to create the toolbar when the
workbook opens and delete it when the workbook closes.

I really like the way John Walkenbach does it in his menumaker workbook:
http://j-walk.com/ss/excel/tips/tip53.htm

Here's how I do it when I want a toolbar:
http://www.contextures.com/xlToolbar02.html
(from Debra Dalgleish's site)

GLT wrote:

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 worksheet 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 worksheet stays
permanently on the worksheet when it's emailed to others?

Thanks...


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
GLT
 
Posts: n/a
Default Adding Customised Buttons to a toolbar

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 worksheet
(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" wrote in message
...
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 worksheet 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 worksheet

stays
permanently on the worksheet when it's emailed to others?

Thanks...




  #5   Report Post  
Posted to microsoft.public.excel.misc
Norman Jones
 
Posts: n/a
Default Adding Customised Buttons to a toolbar

Hi GLT,

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?


There is a small typo in the first line of each macro, change:

With Application.CommandBars("Formating")


to:

With Application.CommandBars("Formatting")



---
Regards,
Norman




  #6   Report Post  
Posted to microsoft.public.excel.misc
GLT
 
Posts: n/a
Default Adding Customised Buttons to a toolbar

Hi,

I have fixed the Formatting, and the code executes ok (I put a couple of
Msgbox in the code), but no buttons appear when I open my document...

Can anyone advise what maybe going wrong?

"Norman Jones" wrote:

Hi GLT,

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?


There is a small typo in the first line of each macro, change:

With Application.CommandBars("Formating")


to:

With Application.CommandBars("Formatting")



---
Regards,
Norman



  #7   Report Post  
Posted to microsoft.public.excel.misc
Desert Piranha
 
Posts: n/a
Default Adding Customised Buttons to a toolbar


GLT Wrote:
Hi,

I have fixed the Formatting, and the code executes ok (I put a couple
of
Msgbox in the code), but no buttons appear when I open my document...

Can anyone advise what maybe going wrong?

"Norman Jones" wrote:

Hi GLT,

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?


There is a small typo in the first line of each macro, change:

With Application.CommandBars("Formating")


to:

With Application.CommandBars("Formatting")



---
Regards,
Norman


Hi GLT,


This code works fine for me. Are you putting the code into the
"WorkBook" Module?
As they are attaching the buttons to the Formatting Toolbar are you
sure you have
enough room on your screen for all the buttons of that toolbar to show?
(horizontally)
I believe you will have to save and reopen the WorkBook.


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=512460

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toolbar buttons -- AS400 iSeries Transfer surg4u1975 Excel Discussion (Misc queries) 0 December 27th 05 07:28 PM
I keep losing Toolbar buttons weberts2 Excel Discussion (Misc queries) 7 July 27th 05 08:51 PM
How can I keep Toolbar Buttons on the toolbar? weberts2 Setting up and Configuration of Excel 1 July 16th 05 04:30 AM
Toolbar Buttons bmac Excel Discussion (Misc queries) 2 March 8th 05 11:05 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 02:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"