lior03
02-02-2006, 01:39 AM
hello all
i have vba code for a toolbar . i place it's name in workbook open event.
i keep getting an error message.
why?
the code:
Sub cmd()
Dim newbtn As CommandBarButton
Application.CommandBars.Add ("johnske")
With CommandBars("johnske")
.Position = msoBarTop
.Visible = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 375
.OnAction = "vin1"
.Caption = "filter data"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 325
.OnAction = "findafile"
.Caption = "open a file"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 469
.OnAction = "sortworksheets"
.Caption = "sort ws"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 353
.OnAction = "lookfor_demo2"
.Caption = "partial text"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 383
.OnAction = "nnnn"
.Caption = "update comments"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 384
.OnAction = "rowme3"
.Caption = "shade altenate rows"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 395
.OnAction = "horin"
.Caption = "accounting format"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 386
.OnAction = "finders44"
.Caption = "find text"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 387
.OnAction = "closeallbut"
.Caption = "closeallbut"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 396
.OnAction = "daphnebook"
.Caption = "vbaexpress"
.BeginGroup = True
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End Sub
thanks
i have vba code for a toolbar . i place it's name in workbook open event.
i keep getting an error message.
why?
the code:
Sub cmd()
Dim newbtn As CommandBarButton
Application.CommandBars.Add ("johnske")
With CommandBars("johnske")
.Position = msoBarTop
.Visible = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 375
.OnAction = "vin1"
.Caption = "filter data"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 325
.OnAction = "findafile"
.Caption = "open a file"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 469
.OnAction = "sortworksheets"
.Caption = "sort ws"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 353
.OnAction = "lookfor_demo2"
.Caption = "partial text"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 383
.OnAction = "nnnn"
.Caption = "update comments"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 384
.OnAction = "rowme3"
.Caption = "shade altenate rows"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 395
.OnAction = "horin"
.Caption = "accounting format"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 386
.OnAction = "finders44"
.Caption = "find text"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 387
.OnAction = "closeallbut"
.Caption = "closeallbut"
.BeginGroup = True
Set newbtn = CommandBars("johnske").Controls.Add(Type:=msoControlButton)
With newbtn
.FaceId = 396
.OnAction = "daphnebook"
.Caption = "vbaexpress"
.BeginGroup = True
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End Sub
thanks