PC Review


Reply
Thread Tools Rate Thread

Can anyone help toolbar struggle

 
 
Rivers
Guest
Posts: n/a
 
      1st Nov 2008
The code below is a toolbar that uses a menu option and then also a sub menu
but i cant figure out how to get the sub menu buttons to add to it can anyone
help


rivers

Sub newbar1()
Application.ScreenUpdating = False
On Error Resume Next

Application.CommandBars("saveas").Delete
With Application.CommandBars.Add
.Name = "Saveas"
.Visible = True
.Position = msoBarTop

' Help

Set cbp = CommandBars("saveas").Controls.Add(Type:=msoControlPopup,
Temporary:=False)
cbp.Caption = "Help.."

Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
With mysubmenu
..Caption = "Useful Websites"
End With

Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
With check
Set cbb = check.Controls.Add
cbb.Caption = "Google"
cbb.OnAction = "google1"
cbb.Style = msoButtonIconAndCaption
cbb.FaceId = 9026 '218 + ictr
cbb.TooltipText = "Search engine"

End With
End With
End Sub
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      1st Nov 2008
Good practice...
Use Option Explicit in all modules
Declare all variables
Be careful when using On Error Resume Next when developing code as
it hides problems.
'--
Sub newbar1()
Application.ScreenUpdating = False
Dim cbp As CommandBarControl
Dim mysubmenu As CommandBarControl
Dim check As CommandBarButton

On Error Resume Next
Application.CommandBars("saveas").Delete
On Error GoTo 0 '<<<

With Application.CommandBars.Add
.Name = "Saveas"
.Visible = True
.Position = msoBarTop
End With

Set cbp = CommandBars("saveas").Controls.AddType:=msoControlPopup, _
Temporary:=False)
cbp.Caption = "Help.. "

Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
mysubmenu.Caption = "Useful Websites"

Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
With check
.Caption = "Google"
.OnAction = "google1"
.Style = msoButtonIconAndCaption
.FaceId = 1234 '9026 '218 + ictr
' .TooltipText = "Search engine"
End With
Application.ScreenUpdating = True
End Sub
--
Jim Cone
Portland, Oregon USA




"Rivers"
wrote in message
The code below is a toolbar that uses a menu option and then also a sub menu
but i cant figure out how to get the sub menu buttons to add to it can anyone
help
rivers

Sub newbar1()
Application.ScreenUpdating = False
On Error Resume Next

Application.CommandBars("saveas").Delete
With Application.CommandBars.Add
.Name = "Saveas"
.Visible = True
.Position = msoBarTop
' Help
Set cbp = CommandBars("saveas").Controls.Add(Type:=msoControlPopup,
Temporary:=False)
cbp.Caption = "Help.."
Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
With mysubmenu
..Caption = "Useful Websites"
End With
Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
With check
Set cbb = check.Controls.Add
cbb.Caption = "Google"
cbb.OnAction = "google1"
cbb.Style = msoButtonIconAndCaption
cbb.FaceId = 9026 '218 + ictr
cbb.TooltipText = "Search engine"
End With
End With
End Sub
 
Reply With Quote
 
Rivers
Guest
Posts: n/a
 
      1st Nov 2008
Hi Jim sorry or not putting the variables in the snippit of code forgot to
sorry.

jim how do i add more than one button i tried but cant

can you help?

"Jim Cone" wrote:

> Good practice...
> Use Option Explicit in all modules
> Declare all variables
> Be careful when using On Error Resume Next when developing code as
> it hides problems.
> '--
> Sub newbar1()
> Application.ScreenUpdating = False
> Dim cbp As CommandBarControl
> Dim mysubmenu As CommandBarControl
> Dim check As CommandBarButton
>
> On Error Resume Next
> Application.CommandBars("saveas").Delete
> On Error GoTo 0 '<<<
>
> With Application.CommandBars.Add
> .Name = "Saveas"
> .Visible = True
> .Position = msoBarTop
> End With
>
> Set cbp = CommandBars("saveas").Controls.AddType:=msoControlPopup, _
> Temporary:=False)
> cbp.Caption = "Help.. "
>
> Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
> mysubmenu.Caption = "Useful Websites"
>
> Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> With check
> .Caption = "Google"
> .OnAction = "google1"
> .Style = msoButtonIconAndCaption
> .FaceId = 1234 '9026 '218 + ictr
> ' .TooltipText = "Search engine"
> End With
> Application.ScreenUpdating = True
> End Sub
> --
> Jim Cone
> Portland, Oregon USA
>
>
>
>
> "Rivers"
> wrote in message
> The code below is a toolbar that uses a menu option and then also a sub menu
> but i cant figure out how to get the sub menu buttons to add to it can anyone
> help
> rivers
>
> Sub newbar1()
> Application.ScreenUpdating = False
> On Error Resume Next
>
> Application.CommandBars("saveas").Delete
> With Application.CommandBars.Add
> .Name = "Saveas"
> .Visible = True
> .Position = msoBarTop
> ' Help
> Set cbp = CommandBars("saveas").Controls.Add(Type:=msoControlPopup,
> Temporary:=False)
> cbp.Caption = "Help.."
> Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
> With mysubmenu
> ..Caption = "Useful Websites"
> End With
> Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> With check
> Set cbb = check.Controls.Add
> cbb.Caption = "Google"
> cbb.OnAction = "google1"
> cbb.Style = msoButtonIconAndCaption
> cbb.FaceId = 9026 '218 + ictr
> cbb.TooltipText = "Search engine"
> End With
> End With
> End Sub
>

 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      1st Nov 2008
Just repeat the "check" section as many times as necessary...
'--
Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
With check
.Caption = "Foogle"
.OnAction = "Foogle2"
.Style = msoButtonIconAndCaption
.FaceId = 2345
End With
'--
Jim Cone
Portland, Oregon USA




"Rivers"
wrote in message
Hi Jim sorry or not putting the variables in the snippit of code forgot to
sorry.
jim how do i add more than one button i tried but cant
can you help?



"Jim Cone" wrote:
> Good practice...
> Use Option Explicit in all modules
> Declare all variables
> Be careful when using On Error Resume Next when developing code as
> it hides problems.
> '--
> Sub newbar1()
> Application.ScreenUpdating = False
> Dim cbp As CommandBarControl
> Dim mysubmenu As CommandBarControl
> Dim check As CommandBarButton
>
> On Error Resume Next
> Application.CommandBars("saveas").Delete
> On Error GoTo 0 '<<<
>
> With Application.CommandBars.Add
> .Name = "Saveas"
> .Visible = True
> .Position = msoBarTop
> End With
>
> Set cbp = Application.CommandBars("saveas").Controls _
> .AddType:=msoControlPopup, Temporary:=False)
> cbp.Caption = "Help.. "
>
> Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
> mysubmenu.Caption = "Useful Websites"
>
> Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> With check
> .Caption = "Google"
> .OnAction = "google1"
> .Style = msoButtonIconAndCaption
> .FaceId = 1234 '9026 '218 + ictr
> ' .TooltipText = "Search engine"
> End With
> Application.ScreenUpdating = True
> End Sub
> --
> Jim Cone
> Portland, Oregon USA


 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      1st Nov 2008
Jim,

I'm wanting to do something similar for Excel 2007. Can you direct me to
some code for that or is it the same?

Thanks,
Barb Reinhardt

"Jim Cone" wrote:

> Just repeat the "check" section as many times as necessary...
> '--
> Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> With check
> .Caption = "Foogle"
> .OnAction = "Foogle2"
> .Style = msoButtonIconAndCaption
> .FaceId = 2345
> End With
> '--
> Jim Cone
> Portland, Oregon USA
>
>
>
>
> "Rivers"
> wrote in message
> Hi Jim sorry or not putting the variables in the snippit of code forgot to
> sorry.
> jim how do i add more than one button i tried but cant
> can you help?
>
>
>
> "Jim Cone" wrote:
> > Good practice...
> > Use Option Explicit in all modules
> > Declare all variables
> > Be careful when using On Error Resume Next when developing code as
> > it hides problems.
> > '--
> > Sub newbar1()
> > Application.ScreenUpdating = False
> > Dim cbp As CommandBarControl
> > Dim mysubmenu As CommandBarControl
> > Dim check As CommandBarButton
> >
> > On Error Resume Next
> > Application.CommandBars("saveas").Delete
> > On Error GoTo 0 '<<<
> >
> > With Application.CommandBars.Add
> > .Name = "Saveas"
> > .Visible = True
> > .Position = msoBarTop
> > End With
> >
> > Set cbp = Application.CommandBars("saveas").Controls _
> > .AddType:=msoControlPopup, Temporary:=False)
> > cbp.Caption = "Help.. "
> >
> > Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
> > mysubmenu.Caption = "Useful Websites"
> >
> > Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> > With check
> > .Caption = "Google"
> > .OnAction = "google1"
> > .Style = msoButtonIconAndCaption
> > .FaceId = 1234 '9026 '218 + ictr
> > ' .TooltipText = "Search engine"
> > End With
> > Application.ScreenUpdating = True
> > End Sub
> > --
> > Jim Cone
> > Portland, Oregon USA

>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      2nd Nov 2008
Ron de Bruin has lots of tips here:
http://www.rondebruin.nl/tips.htm

You may want the QAT or Ribbon modification page???

Barb Reinhardt wrote:
>
> Jim,
>
> I'm wanting to do something similar for Excel 2007. Can you direct me to
> some code for that or is it the same?
>
> Thanks,
> Barb Reinhardt
>
> "Jim Cone" wrote:
>
> > Just repeat the "check" section as many times as necessary...
> > '--
> > Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> > With check
> > .Caption = "Foogle"
> > .OnAction = "Foogle2"
> > .Style = msoButtonIconAndCaption
> > .FaceId = 2345
> > End With
> > '--
> > Jim Cone
> > Portland, Oregon USA
> >
> >
> >
> >
> > "Rivers"
> > wrote in message
> > Hi Jim sorry or not putting the variables in the snippit of code forgot to
> > sorry.
> > jim how do i add more than one button i tried but cant
> > can you help?
> >
> >
> >
> > "Jim Cone" wrote:
> > > Good practice...
> > > Use Option Explicit in all modules
> > > Declare all variables
> > > Be careful when using On Error Resume Next when developing code as
> > > it hides problems.
> > > '--
> > > Sub newbar1()
> > > Application.ScreenUpdating = False
> > > Dim cbp As CommandBarControl
> > > Dim mysubmenu As CommandBarControl
> > > Dim check As CommandBarButton
> > >
> > > On Error Resume Next
> > > Application.CommandBars("saveas").Delete
> > > On Error GoTo 0 '<<<
> > >
> > > With Application.CommandBars.Add
> > > .Name = "Saveas"
> > > .Visible = True
> > > .Position = msoBarTop
> > > End With
> > >
> > > Set cbp = Application.CommandBars("saveas").Controls _
> > > .AddType:=msoControlPopup, Temporary:=False)
> > > cbp.Caption = "Help.. "
> > >
> > > Set mysubmenu = cbp.Controls.Add(Type:=msoControlPopup)
> > > mysubmenu.Caption = "Useful Websites"
> > >
> > > Set check = mysubmenu.Controls.Add(Type:=msoControlButton)
> > > With check
> > > .Caption = "Google"
> > > .OnAction = "google1"
> > > .Style = msoButtonIconAndCaption
> > > .FaceId = 1234 '9026 '218 + ictr
> > > ' .TooltipText = "Search engine"
> > > End With
> > > Application.ScreenUpdating = True
> > > End Sub
> > > --
> > > Jim Cone
> > > Portland, Oregon USA

> >
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure alignment struggle. A n g l e r Microsoft C# .NET 9 24th Jun 2008 11:20 PM
Phew what a struggle !! Abarbarian Gaming 11 25th Nov 2007 11:48 PM
Class struggle =?Utf-8?B?RGF2aWQgR2Vyc3RtYW4=?= Microsoft Excel Programming 5 11th Sep 2007 05:53 PM
Concatenation Struggle =?Utf-8?B?RGFycmlu?= Microsoft Excel Programming 4 14th Feb 2006 10:04 PM
Struggle with The Move to .NET =?Utf-8?B?TWljaGFlbCBHZWlzdA==?= Microsoft ASP .NET 21 24th Nov 2004 09:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:24 PM.