View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Creating a CommandBar - what's wrong?

The only thing I can find wrong with it is that all of the properties are
not dot qualified. Doing that it worked for me

Private Sub CreateCommandBar()
Dim TBar As CommandBar, NewBtna
Set TBar = CommandBars.Add
With TBar
..name = "OPLToolBar"
..top = 0
..left = 0
..Visible = True
End With

Set newBtn1 = CommandBars("OPLToolBar").Controls.Add _
(Type:=msoControlButton, temporary:=True)
With newBtn1
..FaceId = 481
..OnAction = "Sort"
..Caption = "Main Sort"
..Style = msoButtonIconAndCaption
End With

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Eager2Learn " wrote in message
...
I am working on creating a commandbar and buttons upon the worksheet
opening, and then delete it when the worksheet closes. I am new at
this, and running into a problem.

Here is my code so far, it doesn't work. In the Workbook_Open I put a
Call to this:


Private Sub CreateCommandBar()
Dim TBar As CommandBar
Set TBar = CommandBars.Add
With TBar
Name = "OPLToolBar"
Top = 0
Left = 0
Visible = True
End With

Set NewBtn1 = CommandBars("OPLToolBar").Controls.Add _
(Type:=msoControlButton)
With NewBtn1
FaceId = 481
OnAction = "Sort"
Caption = "Main Sort"
Style = msoButtonIconAndCaption
End With

End Sub

Thanks in advance for the help.
Jonathan


---
Message posted from http://www.ExcelForum.com/