PC Review


Reply
Thread Tools Rate Thread

Custom Floatable Toolbar Popup Menu

 
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      13th Jun 2007
I know how to make custom toolbars in Excel and through VBA. Is it possible
to make popup menus within a toolbar that are floatable (similar to the font
and cell color pallettes)?

Thanks,
Pflugs
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      13th Jun 2007
Just for ideas -

Sub CustomBar()
Dim cbr As CommandBar
Dim cbt As CommandBarButton
On Error Resume Next
Application.CommandBars("TestBar").Delete
On Error GoTo 0

Set cbr = Application.CommandBars.Add("TestBar")

Set cbt = cbr.Controls.Add(1)

With cbt
.Style = msoButtonCaption
.Caption = "click for Pop-up"
.Visible = True
.OnAction = "myPopup"
End With

cbr.Position = msoBarFloating
cbr.Visible = True

End Sub

Sub myPopup()
Dim cbr As CommandBar
Dim cbt As CommandBarButton
On Error Resume Next
CommandBars("myPopup").Delete
On Error GoTo 0

Set cbr = Application.CommandBars.Add("myPopup", msoBarPopup, , True)

For i = 80 To 89
Set cbt = cbr.Controls.Add(1, , , , True)
With cbt
.Style = msoButtonIconAndCaption
.Caption = "code " & Chr(i - 15)
.FaceId = i
.Parameter = i - 79
.Visible = True
.OnAction = "myMacro"
End With
Next
On Error GoTo errH

cbr.ShowPopup

done:
cbr.Delete
Exit Sub
errH:
Resume done
End Sub

Sub MyMacro()
Dim cbt As CommandBarButton
Dim sParam As String

Set cbt = Application.CommandBars.ActionControl
sParam = cbt.Parameter
MsgBox "button " & sParam, , cbt.Caption

Select Case sParam
Case "1"
MsgBox "processing code " & sParam
'etc
End Select
End Sub

Regards,
Peter T


"Pflugs" <(E-Mail Removed)> wrote in message
news:4B92C17F-5D62-42B2-8D75-(E-Mail Removed)...
> I know how to make custom toolbars in Excel and through VBA. Is it

possible
> to make popup menus within a toolbar that are floatable (similar to the

font
> and cell color pallettes)?
>
> Thanks,
> Pflugs



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      13th Jun 2007
Should include 'OnError Resume Next' just after 'done:'

> On Error GoTo errH
>
> cbr.ShowPopup
>
> done:


OnError Resume Next ' >> add this line

> cbr.Delete
> Exit Sub
> errH:
> Resume done
> End Sub



Peter T


> On Error Resume Next
> cbr.ShowPopup

"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> Just for ideas -
>
> Sub CustomBar()
> Dim cbr As CommandBar
> Dim cbt As CommandBarButton
> On Error Resume Next
> Application.CommandBars("TestBar").Delete
> On Error GoTo 0
>
> Set cbr = Application.CommandBars.Add("TestBar")
>
> Set cbt = cbr.Controls.Add(1)
>
> With cbt
> .Style = msoButtonCaption
> .Caption = "click for Pop-up"
> .Visible = True
> .OnAction = "myPopup"
> End With
>
> cbr.Position = msoBarFloating
> cbr.Visible = True
>
> End Sub
>
> Sub myPopup()
> Dim cbr As CommandBar
> Dim cbt As CommandBarButton
> On Error Resume Next
> CommandBars("myPopup").Delete
> On Error GoTo 0
>
> Set cbr = Application.CommandBars.Add("myPopup", msoBarPopup, , True)
>
> For i = 80 To 89
> Set cbt = cbr.Controls.Add(1, , , , True)
> With cbt
> .Style = msoButtonIconAndCaption
> .Caption = "code " & Chr(i - 15)
> .FaceId = i
> .Parameter = i - 79
> .Visible = True
> .OnAction = "myMacro"
> End With
> Next
> On Error GoTo errH
>
> cbr.ShowPopup
>
> done:
> cbr.Delete
> Exit Sub
> errH:
> Resume done
> End Sub
>
> Sub MyMacro()
> Dim cbt As CommandBarButton
> Dim sParam As String
>
> Set cbt = Application.CommandBars.ActionControl
> sParam = cbt.Parameter
> MsgBox "button " & sParam, , cbt.Caption
>
> Select Case sParam
> Case "1"
> MsgBox "processing code " & sParam
> 'etc
> End Select
> End Sub
>
> Regards,
> Peter T
>
>
> "Pflugs" <(E-Mail Removed)> wrote in message
> news:4B92C17F-5D62-42B2-8D75-(E-Mail Removed)...
> > I know how to make custom toolbars in Excel and through VBA. Is it

> possible
> > to make popup menus within a toolbar that are floatable (similar to the

> font
> > and cell color pallettes)?
> >
> > Thanks,
> > Pflugs

>
>



 
Reply With Quote
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      14th Jun 2007
That's really neat and definitely useful. Any idea on how to make that popup
menu moveable and remain on the screen when you click away?

"Peter T" wrote:

> Should include 'OnError Resume Next' just after 'done:'
>
> > On Error GoTo errH
> >
> > cbr.ShowPopup
> >
> > done:

>
> OnError Resume Next ' >> add this line
>
> > cbr.Delete
> > Exit Sub
> > errH:
> > Resume done
> > End Sub

>
>
> Peter T
>
>
> > On Error Resume Next
> > cbr.ShowPopup

> "Peter T" <peter_t@discussions> wrote in message
> news:(E-Mail Removed)...
> > Just for ideas -
> >
> > Sub CustomBar()
> > Dim cbr As CommandBar
> > Dim cbt As CommandBarButton
> > On Error Resume Next
> > Application.CommandBars("TestBar").Delete
> > On Error GoTo 0
> >
> > Set cbr = Application.CommandBars.Add("TestBar")
> >
> > Set cbt = cbr.Controls.Add(1)
> >
> > With cbt
> > .Style = msoButtonCaption
> > .Caption = "click for Pop-up"
> > .Visible = True
> > .OnAction = "myPopup"
> > End With
> >
> > cbr.Position = msoBarFloating
> > cbr.Visible = True
> >
> > End Sub
> >
> > Sub myPopup()
> > Dim cbr As CommandBar
> > Dim cbt As CommandBarButton
> > On Error Resume Next
> > CommandBars("myPopup").Delete
> > On Error GoTo 0
> >
> > Set cbr = Application.CommandBars.Add("myPopup", msoBarPopup, , True)
> >
> > For i = 80 To 89
> > Set cbt = cbr.Controls.Add(1, , , , True)
> > With cbt
> > .Style = msoButtonIconAndCaption
> > .Caption = "code " & Chr(i - 15)
> > .FaceId = i
> > .Parameter = i - 79
> > .Visible = True
> > .OnAction = "myMacro"
> > End With
> > Next
> > On Error GoTo errH
> >
> > cbr.ShowPopup
> >
> > done:
> > cbr.Delete
> > Exit Sub
> > errH:
> > Resume done
> > End Sub
> >
> > Sub MyMacro()
> > Dim cbt As CommandBarButton
> > Dim sParam As String
> >
> > Set cbt = Application.CommandBars.ActionControl
> > sParam = cbt.Parameter
> > MsgBox "button " & sParam, , cbt.Caption
> >
> > Select Case sParam
> > Case "1"
> > MsgBox "processing code " & sParam
> > 'etc
> > End Select
> > End Sub
> >
> > Regards,
> > Peter T
> >
> >
> > "Pflugs" <(E-Mail Removed)> wrote in message
> > news:4B92C17F-5D62-42B2-8D75-(E-Mail Removed)...
> > > I know how to make custom toolbars in Excel and through VBA. Is it

> > possible
> > > to make popup menus within a toolbar that are floatable (similar to the

> > font
> > > and cell color pallettes)?
> > >
> > > Thanks,
> > > Pflugs

> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      14th Jun 2007
Upon some futher testing, I found that the type of control I'm talking about
is msoControlSplitButtonPopup. I can create these as long as they have
predefined ID's. I can't figure out how to create them from scratch and add
my own controls to them. Anyone have any thoughts?

Thanks,
Pflugs

"Peter T" wrote:

> Should include 'OnError Resume Next' just after 'done:'
>
> > On Error GoTo errH
> >
> > cbr.ShowPopup
> >
> > done:

>
> OnError Resume Next ' >> add this line
>
> > cbr.Delete
> > Exit Sub
> > errH:
> > Resume done
> > End Sub

>
>
> Peter T
>
>
> > On Error Resume Next
> > cbr.ShowPopup

> "Peter T" <peter_t@discussions> wrote in message
> news:(E-Mail Removed)...
> > Just for ideas -
> >
> > Sub CustomBar()
> > Dim cbr As CommandBar
> > Dim cbt As CommandBarButton
> > On Error Resume Next
> > Application.CommandBars("TestBar").Delete
> > On Error GoTo 0
> >
> > Set cbr = Application.CommandBars.Add("TestBar")
> >
> > Set cbt = cbr.Controls.Add(1)
> >
> > With cbt
> > .Style = msoButtonCaption
> > .Caption = "click for Pop-up"
> > .Visible = True
> > .OnAction = "myPopup"
> > End With
> >
> > cbr.Position = msoBarFloating
> > cbr.Visible = True
> >
> > End Sub
> >
> > Sub myPopup()
> > Dim cbr As CommandBar
> > Dim cbt As CommandBarButton
> > On Error Resume Next
> > CommandBars("myPopup").Delete
> > On Error GoTo 0
> >
> > Set cbr = Application.CommandBars.Add("myPopup", msoBarPopup, , True)
> >
> > For i = 80 To 89
> > Set cbt = cbr.Controls.Add(1, , , , True)
> > With cbt
> > .Style = msoButtonIconAndCaption
> > .Caption = "code " & Chr(i - 15)
> > .FaceId = i
> > .Parameter = i - 79
> > .Visible = True
> > .OnAction = "myMacro"
> > End With
> > Next
> > On Error GoTo errH
> >
> > cbr.ShowPopup
> >
> > done:
> > cbr.Delete
> > Exit Sub
> > errH:
> > Resume done
> > End Sub
> >
> > Sub MyMacro()
> > Dim cbt As CommandBarButton
> > Dim sParam As String
> >
> > Set cbt = Application.CommandBars.ActionControl
> > sParam = cbt.Parameter
> > MsgBox "button " & sParam, , cbt.Caption
> >
> > Select Case sParam
> > Case "1"
> > MsgBox "processing code " & sParam
> > 'etc
> > End Select
> > End Sub
> >
> > Regards,
> > Peter T
> >
> >
> > "Pflugs" <(E-Mail Removed)> wrote in message
> > news:4B92C17F-5D62-42B2-8D75-(E-Mail Removed)...
> > > I know how to make custom toolbars in Excel and through VBA. Is it

> > possible
> > > to make popup menus within a toolbar that are floatable (similar to the

> > font
> > > and cell color pallettes)?
> > >
> > > Thanks,
> > > Pflugs

> >
> >

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      14th Jun 2007
I don't think there's any straightforward way to create this type of
control, or indeed various others.

Depending on what you want to achieve perhaps a cascading menu system (popup
controls rather than popup bars) or even add some more 'squarish'
commandbars.

Regards,
Peter T


"Pflugs" <(E-Mail Removed)> wrote in message
news:491401D2-41EF-48F4-B683-(E-Mail Removed)...
> Upon some futher testing, I found that the type of control I'm talking

about
> is msoControlSplitButtonPopup. I can create these as long as they have
> predefined ID's. I can't figure out how to create them from scratch and

add
> my own controls to them. Anyone have any thoughts?
>
> Thanks,
> Pflugs
>
> "Peter T" wrote:
>
> > Should include 'OnError Resume Next' just after 'done:'
> >
> > > On Error GoTo errH
> > >
> > > cbr.ShowPopup
> > >
> > > done:

> >
> > OnError Resume Next ' >> add this line
> >
> > > cbr.Delete
> > > Exit Sub
> > > errH:
> > > Resume done
> > > End Sub

> >
> >
> > Peter T
> >
> >
> > > On Error Resume Next
> > > cbr.ShowPopup

> > "Peter T" <peter_t@discussions> wrote in message
> > news:(E-Mail Removed)...
> > > Just for ideas -
> > >
> > > Sub CustomBar()
> > > Dim cbr As CommandBar
> > > Dim cbt As CommandBarButton
> > > On Error Resume Next
> > > Application.CommandBars("TestBar").Delete
> > > On Error GoTo 0
> > >
> > > Set cbr = Application.CommandBars.Add("TestBar")
> > >
> > > Set cbt = cbr.Controls.Add(1)
> > >
> > > With cbt
> > > .Style = msoButtonCaption
> > > .Caption = "click for Pop-up"
> > > .Visible = True
> > > .OnAction = "myPopup"
> > > End With
> > >
> > > cbr.Position = msoBarFloating
> > > cbr.Visible = True
> > >
> > > End Sub
> > >
> > > Sub myPopup()
> > > Dim cbr As CommandBar
> > > Dim cbt As CommandBarButton
> > > On Error Resume Next
> > > CommandBars("myPopup").Delete
> > > On Error GoTo 0
> > >
> > > Set cbr = Application.CommandBars.Add("myPopup", msoBarPopup, ,

True)
> > >
> > > For i = 80 To 89
> > > Set cbt = cbr.Controls.Add(1, , , , True)
> > > With cbt
> > > .Style = msoButtonIconAndCaption
> > > .Caption = "code " & Chr(i - 15)
> > > .FaceId = i
> > > .Parameter = i - 79
> > > .Visible = True
> > > .OnAction = "myMacro"
> > > End With
> > > Next
> > > On Error GoTo errH
> > >
> > > cbr.ShowPopup
> > >
> > > done:
> > > cbr.Delete
> > > Exit Sub
> > > errH:
> > > Resume done
> > > End Sub
> > >
> > > Sub MyMacro()
> > > Dim cbt As CommandBarButton
> > > Dim sParam As String
> > >
> > > Set cbt = Application.CommandBars.ActionControl
> > > sParam = cbt.Parameter
> > > MsgBox "button " & sParam, , cbt.Caption
> > >
> > > Select Case sParam
> > > Case "1"
> > > MsgBox "processing code " & sParam
> > > 'etc
> > > End Select
> > > End Sub
> > >
> > > Regards,
> > > Peter T
> > >
> > >
> > > "Pflugs" <(E-Mail Removed)> wrote in message
> > > news:4B92C17F-5D62-42B2-8D75-(E-Mail Removed)...
> > > > I know how to make custom toolbars in Excel and through VBA. Is it
> > > possible
> > > > to make popup menus within a toolbar that are floatable (similar to

the
> > > font
> > > > and cell color pallettes)?
> > > >
> > > > Thanks,
> > > > Pflugs
> > >
> > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      14th Jun 2007
Yes, I think those methods would work better. Thanks for the popup code.
Pflugs

"Peter T" wrote:

> I don't think there's any straightforward way to create this type of
> control, or indeed various others.
>
> Depending on what you want to achieve perhaps a cascading menu system (popup
> controls rather than popup bars) or even add some more 'squarish'
> commandbars.
>
> Regards,
> Peter T
>
>
> "Pflugs" <(E-Mail Removed)> wrote in message
> news:491401D2-41EF-48F4-B683-(E-Mail Removed)...
> > Upon some futher testing, I found that the type of control I'm talking

> about
> > is msoControlSplitButtonPopup. I can create these as long as they have
> > predefined ID's. I can't figure out how to create them from scratch and

> add
> > my own controls to them. Anyone have any thoughts?
> >
> > Thanks,
> > Pflugs
> >
> > "Peter T" wrote:
> >
> > > Should include 'OnError Resume Next' just after 'done:'
> > >
> > > > On Error GoTo errH
> > > >
> > > > cbr.ShowPopup
> > > >
> > > > done:
> > >
> > > OnError Resume Next ' >> add this line
> > >
> > > > cbr.Delete
> > > > Exit Sub
> > > > errH:
> > > > Resume done
> > > > End Sub
> > >
> > >
> > > Peter T
> > >
> > >
> > > > On Error Resume Next
> > > > cbr.ShowPopup
> > > "Peter T" <peter_t@discussions> wrote in message
> > > news:(E-Mail Removed)...
> > > > Just for ideas -
> > > >
> > > > Sub CustomBar()
> > > > Dim cbr As CommandBar
> > > > Dim cbt As CommandBarButton
> > > > On Error Resume Next
> > > > Application.CommandBars("TestBar").Delete
> > > > On Error GoTo 0
> > > >
> > > > Set cbr = Application.CommandBars.Add("TestBar")
> > > >
> > > > Set cbt = cbr.Controls.Add(1)
> > > >
> > > > With cbt
> > > > .Style = msoButtonCaption
> > > > .Caption = "click for Pop-up"
> > > > .Visible = True
> > > > .OnAction = "myPopup"
> > > > End With
> > > >
> > > > cbr.Position = msoBarFloating
> > > > cbr.Visible = True
> > > >
> > > > End Sub
> > > >
> > > > Sub myPopup()
> > > > Dim cbr As CommandBar
> > > > Dim cbt As CommandBarButton
> > > > On Error Resume Next
> > > > CommandBars("myPopup").Delete
> > > > On Error GoTo 0
> > > >
> > > > Set cbr = Application.CommandBars.Add("myPopup", msoBarPopup, ,

> True)
> > > >
> > > > For i = 80 To 89
> > > > Set cbt = cbr.Controls.Add(1, , , , True)
> > > > With cbt
> > > > .Style = msoButtonIconAndCaption
> > > > .Caption = "code " & Chr(i - 15)
> > > > .FaceId = i
> > > > .Parameter = i - 79
> > > > .Visible = True
> > > > .OnAction = "myMacro"
> > > > End With
> > > > Next
> > > > On Error GoTo errH
> > > >
> > > > cbr.ShowPopup
> > > >
> > > > done:
> > > > cbr.Delete
> > > > Exit Sub
> > > > errH:
> > > > Resume done
> > > > End Sub
> > > >
> > > > Sub MyMacro()
> > > > Dim cbt As CommandBarButton
> > > > Dim sParam As String
> > > >
> > > > Set cbt = Application.CommandBars.ActionControl
> > > > sParam = cbt.Parameter
> > > > MsgBox "button " & sParam, , cbt.Caption
> > > >
> > > > Select Case sParam
> > > > Case "1"
> > > > MsgBox "processing code " & sParam
> > > > 'etc
> > > > End Select
> > > > End Sub
> > > >
> > > > Regards,
> > > > Peter T
> > > >
> > > >
> > > > "Pflugs" <(E-Mail Removed)> wrote in message
> > > > news:4B92C17F-5D62-42B2-8D75-(E-Mail Removed)...
> > > > > I know how to make custom toolbars in Excel and through VBA. Is it
> > > > possible
> > > > > to make popup menus within a toolbar that are floatable (similar to

> the
> > > > font
> > > > > and cell color pallettes)?
> > > > >
> > > > > Thanks,
> > > > > Pflugs
> > > >
> > > >
> > >
> > >
> > >

>
>
>

 
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
Custom Popup toolbar Don Microsoft Access 0 19th May 2010 11:16 PM
Displaying A custom menu as a popup menu =?Utf-8?B?ZGlkZHlfZGF2aWQ=?= Microsoft Excel Programming 5 22nd Sep 2007 04:40 AM
Custom Toolbar on Popup Form =?Utf-8?B?S2Vybm93IEdpcmw=?= Microsoft Access Forms 5 28th Mar 2006 12:16 PM
MENU/TOOLBAR ON A POPUP FORM? Derek Brown Microsoft Access Forms 4 27th Jul 2005 08:45 PM
Custom Popup menu in custom control and powerpoint Rajesh Microsoft Powerpoint 1 1st Mar 2004 01:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.