View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
amescha amescha is offline
external usenet poster
 
Posts: 12
Default Assign macro to toolbar custom button?

Dear Tom,

Thank you very much, your code works just as you say it does, viz:

Sub AddButtonTest2()
'
' AddButtonTest2 Macro
' Macro recorded 9/24/2004 by Knight ITC
'
' File name = EquGen.xls
' Toolbar name = EquationCopies
' Toolbar starts without any buttons
' 1st Macro name = CopytoEquationGenerator
' 2nd Macro name = CopytoEquationGeneratorTarget
' 3rd Macro name = CopytoErrorAnalysis
' 4th Macro name = CopytoErrorAnalysis
Dim Cmd As CommandBarButton
Application.CommandBars.Add(Name:="EquationCopies" ).Visible = True
Set Cmd = Application.CommandBars("EquationCopies").Controls .Add( _
Type:=msoControlButton, _
ID:=2950, Befo=1)
Cmd.Caption = "CopyTo"
Cmd.OnAction = "'EquGen.xls'!CopyToEquationGenerator"
Set Cmd = Application.CommandBars("EquationCopies").Controls .Add( _
Type:=msoControlButton, _
ID:=2950, Befo=2)
Cmd.Caption = "CopyTo"
Cmd.OnAction = "'EquGen.xls'!CopyToEquationGeneratorTarget"
Set Cmd = Application.CommandBars("EquationCopies").Controls .Add( _
Type:=msoControlButton, _
ID:=2950, Befo=3)
Cmd.Caption = "CopyTo"
Cmd.OnAction = "'EquGen.xls'!CopyToErrorAnalysis"
Set Cmd = Application.CommandBars("EquationCopies").Controls .Add( _
Type:=msoControlButton, _
ID:=2950, Befo=4)
Cmd.Caption = "CopyTo"
Cmd.OnAction = "'EquGen.xls'!CopyToErrorAnalysisTarget"
End Sub

I have taken the option to remove some of the code dealing with button
duplication since this is going into a Workbook_Open() event in the
"ThisWorkbook" module.

I do get four identical nice simley buttons and would like to make them
different since they do activate seperate procedures. If possible I would
also like to add whatever those little pop-up tips that appear when the mouse
pointer is on a particular button. I'll just start another thread on this
matter. Thanks again!

Charles Ames
University of Oregon