.OnAction Exvel VBA

S

shulinl

All of a sudden, my personal comandbars cannot be added.
Every thing has been working greatly for the past many years.

Excel 2003

please hel.....p.

Do I need to add a certain reference? I only had problem today.
**********************************************
Sub ToolBar_EasyTools()
Dim myToolbar
Dim myControl
On Error GoTo create
MsgBox CommandBars("myBar")

create:
Set myToolbar = CommandBars.Add(Name:="myBar", Position:=msoBarTop,
Temporary:=False)

On Error Resume Next
Set myControl = CommandBars("myBar").Controls.Add(Type:=msoControlButton)
With myControl
.Caption = "sgdasf"
.Visible = True
.OnAction = "temp1"
.Style = msoButtonCaption
End With

'...............etc

CommandBars("myBar").Visible = True

End Sub
 
B

Bob Phillips

Type this in the immediate nwindow and run it until you get an error

Application.Commandbars("myBar").delete

Then change

Set myToolbar = CommandBars.Add(Name:="myBar", Position:=msoBarTop,
Temporary:=False)

to

On Error Resume Next
Application.Commandbars("myBar").delete
On Error Goto 0

Set myToolbar = CommandBars.Add(Name:="myBar", Position:=msoBarTop,
Temporary:=True)


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
J

Jackie

It did not work with Bob's sugestions.

It worked well before this Excel crash. I reinstalled MS Office to no avail.

??
 

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

Can't get Control.State to work 15
Sub menu 3
Custom Toolbar 2
hide menu bar 1
Toolbar Issue 4
Using Excel 2007 with Excel 2003 template 1
Control Bars and Command Buttons?? 1
Excel 2007 Menus 2

Top