One more time (I hope)

S

salgud

The code below is supposed to create a toolbar with one tool on it which
runs a macro which is in a separate module (same workbook)

Public Const sCreateTribTR As String = "CreateTribTr"

Sub Auto_Open()
Call CreateMenubar
With CommandBars(sCreateTribTR)
.Enabled = False
.Visible = False
End With

End Sub

Sub Auto_Close()
Call RemoveMenubar
End Sub

Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars(sCreateTribTR).Delete
On Error GoTo 0
End Sub

Sub CreateMenubar()

Call RemoveMenubar

With Application.CommandBars.Add
.Name = sCreateTribTR
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarTop
.Left = CommandBars(sCreateTribTR).Left +
CommandBars(sCreateTribTR).Width
.RowIndex = CommandBars(sCreateTribTR).RowIndex

With CommandBars(sCreateTribTR).Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "CreateTR"
.Caption = "CreateTR"
.Style = msoButtonCaption
.TooltipText = "Create TR"
End With

With CommandBars(sCreateTribTR).Controls.Add(Type:=msoControlButton, ID _
:=2950, Before:=2)
End With
End With
End Sub

Public Sub CreateTR()
Call CreateTribalSheet
End Sub

It compiles and runs, just nothing happnes. No toolbar. Anybody see what
I'm missing?
 
S

salgud

The code below is supposed to create a toolbar with one tool on it which
runs a macro which is in a separate module (same workbook)

Public Const sCreateTribTR As String = "CreateTribTr"

Sub Auto_Open()
Call CreateMenubar
With CommandBars(sCreateTribTR)
.Enabled = False
.Visible = False
End With

End Sub

Sub Auto_Close()
Call RemoveMenubar
End Sub

Sub RemoveMenubar()
On Error Resume Next
Application.CommandBars(sCreateTribTR).Delete
On Error GoTo 0
End Sub

Sub CreateMenubar()

Call RemoveMenubar

With Application.CommandBars.Add
.Name = sCreateTribTR
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarTop
.Left = CommandBars(sCreateTribTR).Left +
CommandBars(sCreateTribTR).Width
.RowIndex = CommandBars(sCreateTribTR).RowIndex

With CommandBars(sCreateTribTR).Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "CreateTR"
.Caption = "CreateTR"
.Style = msoButtonCaption
.TooltipText = "Create TR"
End With

With CommandBars(sCreateTribTR).Controls.Add(Type:=msoControlButton, ID _
:=2950, Before:=2)
End With
End With
End Sub

Public Sub CreateTR()
Call CreateTribalSheet
End Sub

It compiles and runs, just nothing happnes. No toolbar. Anybody see what
I'm missing?

Thanks, I figured it out!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top