Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Initializing a custom toolbar

I have the following custom toolbar and button assignment. It works if I
manually go through the code but I want it to initialize automatically when
the spreadsheet is opened. How do I do this?

Sub CatalystDumpToolBar()

Dim CDToolBar As CommandBar

Set CDToolBar = CommandBars.Add(temporary:=True)
With CDToolBar
.Name = "CDToolBar"
.Position = msoBarTop
.Visible = True
End With
End Sub

Sub AddCustomControl()

Dim CBar As CommandBar
Dim CTTally As CommandBarControl

Set CBar = CommandBars("CDToolBar")
Set CTTally = CBar.Controls.Add(Type:=msoControlButton)

With CTTally
.FaceId = 1763
.OnAction = "CatalystToTally"
End With
CBar.Visible = True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Initializing a custom toolbar

In the ThisWorkbook module, place the following code:

Private Sub Workbook_Open()

Call CatalystDumpToolBar

Call AddCustomControl

End Sub


--
Please rate this post if it answers your question.

Thanks,

Chris
http://www.ProfessionalExcel.com




"Bishop" wrote:

I have the following custom toolbar and button assignment. It works if I
manually go through the code but I want it to initialize automatically when
the spreadsheet is opened. How do I do this?

Sub CatalystDumpToolBar()

Dim CDToolBar As CommandBar

Set CDToolBar = CommandBars.Add(temporary:=True)
With CDToolBar
.Name = "CDToolBar"
.Position = msoBarTop
.Visible = True
End With
End Sub

Sub AddCustomControl()

Dim CBar As CommandBar
Dim CTTally As CommandBarControl

Set CBar = CommandBars("CDToolBar")
Set CTTally = CBar.Controls.Add(Type:=msoControlButton)

With CTTally
.FaceId = 1763
.OnAction = "CatalystToTally"
End With
CBar.Visible = True

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Initializing a custom toolbar

I need to add a check to see if the toolbar is already present. If it is
then no need for the call. If it isn't then I need to call the two
procedures. How do I do this?

"ProfessionalExcel.com" wrote:

In the ThisWorkbook module, place the following code:

Private Sub Workbook_Open()

Call CatalystDumpToolBar

Call AddCustomControl

End Sub


--
Please rate this post if it answers your question.

Thanks,

Chris
http://www.ProfessionalExcel.com




"Bishop" wrote:

I have the following custom toolbar and button assignment. It works if I
manually go through the code but I want it to initialize automatically when
the spreadsheet is opened. How do I do this?

Sub CatalystDumpToolBar()

Dim CDToolBar As CommandBar

Set CDToolBar = CommandBars.Add(temporary:=True)
With CDToolBar
.Name = "CDToolBar"
.Position = msoBarTop
.Visible = True
End With
End Sub

Sub AddCustomControl()

Dim CBar As CommandBar
Dim CTTally As CommandBarControl

Set CBar = CommandBars("CDToolBar")
Set CTTally = CBar.Controls.Add(Type:=msoControlButton)

With CTTally
.FaceId = 1763
.OnAction = "CatalystToTally"
End With
CBar.Visible = True

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Initializing a custom toolbar

Change the procedure to:

Private Sub Workbook_Open()
Dim intCounter As Integer

For intCounter = 1 To Application.CommandBars.Count
If Application.CommandBars(intCounter).Name = "CDToolBar" Then
Exit Sub
Next intCounter

Call CatalystDumpToolBar

Call AddCustomControl

End Sub


Also, if you want to delete the toolbar at any point, use the following
procedu

Sub DeleteMenu()

Dim intCounter As Integer

For intCounter = Application.CommandBars.Count To 1 Step -1
If Application.CommandBars(intCounter).Name = "CDToolBar" Then
Application.CommandBars(intCounter).Delete
End If
Next intCounter

End Sub


----------------------------
Please rate this post if it answers your question.

Thanks,

Chris
http://www.ProfessionalExcel.com


"Bishop" wrote:

I need to add a check to see if the toolbar is already present. If it is
then no need for the call. If it isn't then I need to call the two
procedures. How do I do this?

"ProfessionalExcel.com" wrote:

In the ThisWorkbook module, place the following code:

Private Sub Workbook_Open()

Call CatalystDumpToolBar

Call AddCustomControl

End Sub


--
Please rate this post if it answers your question.

Thanks,

Chris
http://www.ProfessionalExcel.com




"Bishop" wrote:

I have the following custom toolbar and button assignment. It works if I
manually go through the code but I want it to initialize automatically when
the spreadsheet is opened. How do I do this?

Sub CatalystDumpToolBar()

Dim CDToolBar As CommandBar

Set CDToolBar = CommandBars.Add(temporary:=True)
With CDToolBar
.Name = "CDToolBar"
.Position = msoBarTop
.Visible = True
End With
End Sub

Sub AddCustomControl()

Dim CBar As CommandBar
Dim CTTally As CommandBarControl

Set CBar = CommandBars("CDToolBar")
Set CTTally = CBar.Controls.Add(Type:=msoControlButton)

With CTTally
.FaceId = 1763
.OnAction = "CatalystToTally"
End With
CBar.Visible = True

End Sub

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
hide custom toolbar from Toolbar list tracktraining Excel Programming 3 February 26th 09 09:28 PM
Need help w using custom image for custom toolbar in Excel 2007 vbaexperimenter Excel Programming 10 June 23rd 08 06:05 PM
adding custom images to a button on custom toolbar Mousam Excel Programming 1 July 13th 07 04:28 PM
custom toolbar buttons are saved where? Excel loads twice bymistake and all my custom toolbar buttons get gone!!! Kevin Waite Excel Programming 2 March 3rd 04 03:31 PM
saving toolbar buttons on custom toolbar Paul James Excel Programming 12 August 6th 03 08:28 AM


All times are GMT +1. The time now is 10:50 AM.

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

About Us

"It's about Microsoft Excel"