View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Exel2000 VBA - Creating a Command Bar - Error: "Object Variable or With not Set"


In addition to Tom's remark:

I see a hard return but no line continuation where you add the Button?

Use:

Set btnRun = barTemp.Controls.Add _
(Type:=msoControlButton, temporary:=True)


Also:

Dim btnRun as Office.CommandBarButton

the CommandBarControl is more generic.. if u use CommandBarButton Object
you'll see more properties to work with.


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Tom Ogilvy" wrote:

in the workbook_open event you should prefix with application


Private Sub Workbook_Open()
Dim barTemp As CommandBar
Dim btnRun As CommandBarControl

Set barTemp = Application.CommandBars.Add(Name:="Temp", _
Position:=msoBarFloating, MenuBar:=False, temporary:=True)

Set btnRun = barTemp.Controls.Add
(Type:=msoControlButton, temporary:=True)

End Sub

This usually clears up this type of problem.