LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create toolbar with VB (notVBA)?

Thank you Steve. I did say I did it from VBA <vbg

--

HTH

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

"Steve Garman" wrote in message
...
Just one small point about using Bob's code in VB

There are 3 constants VB won't recognize

msoControlPopup = 10
msoControlButton = 1
msoButtonCaption = 2

Just replace them with the appropriate number or define your own constants

Bob Phillips wrote:
Ed,

I just knocked up this bit of code and ran it okay. Admittedly, it was

in
VBA, but it uses automation so it will work just as well in VB

Sub myMenu()
Dim oCB As Object
Dim oCtl As Object 'CommandBarControl
Dim newMenu As Object 'CommandBarControl
Dim ctrlButton As Object 'CommandBarControl
Dim xlApp As Object
Dim sh As Object

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True

On Error Resume Next
xlApp.CommandBars("Worksheet Menu
Bar").Controls("Tools").Controls("Bars2004").Delet e
On Error GoTo 0

Set oCB = xlApp.CommandBars("Worksheet Menu Bar")
Set oCtl = oCB.Controls("Tools")

Set newMenu = oCtl.Controls.Add(Type:=msoControlPopup,

temporary:=True)
With newMenu
.Caption = "myMenu"
Set ctrlButton = .Controls.Add(Type:=msoControlButton, ID:=1)
With ctrlButton
.Caption = "mySubMenu"
.Style = msoButtonCaption
.OnAction = "myMacro"
End With
End With

End Sub

This should give you a start.

You don't need to use late binding, you could just as easily set a

reference
to Excel, and use early binding, declaring the objects explicitly.




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Toolbar Button Andy Excel Discussion (Misc queries) 3 December 31st 08 04:17 PM
Macro code to create a toolbar? Do what I can, but I''m only one man. Excel Discussion (Misc queries) 3 October 24th 08 12:08 AM
How do i create a second quick access toolbar Sue Parsons Excel Worksheet Functions 0 November 12th 07 04:33 PM
How do you create a pdf toolbar on excel? Jac Excel Discussion (Misc queries) 1 March 17th 06 09:44 AM
How do I create a new toolbar with different tickmark buttoms? lgpalhares Excel Discussion (Misc queries) 2 October 11th 05 09:35 PM


All times are GMT +1. The time now is 09:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"