PC Review


Reply
Thread Tools Rate Thread

Commandbar works first pass, but not thereafter

 
 
=?Utf-8?B?RGFsZSBGeWU=?=
Guest
Posts: n/a
 
      22nd Oct 2007
I've added a commandbar (see code below) to my userform, which pops up
another userform. The first time I open this command bar and click on the
POC Info button, it opens the second form properly, but when I select click
on the label that pops this menu up a second time, there is a check in front
of the POC Info option, and clicking on it does nothing.

Any ideas what I am doing wrong?

Sub OptionsMenu()

Dim CmdBar As Office.CommandBar
Dim ctrl As Office.CommandBarControl

On Error Resume Next
Application.CommandBars("MyOptions").Delete
On Error GoTo 0

Set CmdBar = Application.CommandBars.Add(Name:="MyOptions", _

Position:=msoBarPopup, _
temporary:=True)

Set ctrl = CmdBar.Controls.Add(Type:=msoControlButton)
With ctrl
.Caption = "POC info"
.OnAction = "POC_Info"
End With

End Sub

Public Sub POC_Info()

Userform1.Hide
frm_POC_Info.Show
Userform1.Show

End Sub

Dale
--
Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFsZSBGeWU=?=
Guest
Posts: n/a
 
      23rd Oct 2007
I resolved this by setting the CommandBarButton State property to msoButtonUp
in the subroutine that was called during the OnAction call.

It was either that, or changing: Userform1.Show
to: Userform1.Show 0

Dale
--
Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.


"Dale Fye" wrote:

> I've added a commandbar (see code below) to my userform, which pops up
> another userform. The first time I open this command bar and click on the
> POC Info button, it opens the second form properly, but when I select click
> on the label that pops this menu up a second time, there is a check in front
> of the POC Info option, and clicking on it does nothing.
>
> Any ideas what I am doing wrong?
>
> Sub OptionsMenu()
>
> Dim CmdBar As Office.CommandBar
> Dim ctrl As Office.CommandBarControl
>
> On Error Resume Next
> Application.CommandBars("MyOptions").Delete
> On Error GoTo 0
>
> Set CmdBar = Application.CommandBars.Add(Name:="MyOptions", _
>
> Position:=msoBarPopup, _
> temporary:=True)
>
> Set ctrl = CmdBar.Controls.Add(Type:=msoControlButton)
> With ctrl
> .Caption = "POC info"
> .OnAction = "POC_Info"
> End With
>
> End Sub
>
> Public Sub POC_Info()
>
> Userform1.Hide
> frm_POC_Info.Show
> Userform1.Show
>
> End Sub
>
> Dale
> --
> Don''t forget to rate the post if it was helpful!
>
> Email address is not valid.
> Please reply to newsgroup only.

 
Reply With Quote
 
Dave D-C
Guest
Posts: n/a
 
      23rd Oct 2007
Dale,
I've had that too. I can't explain why your setup doesn't work,
but this does.

Dim gblUF2% ' a global variable

Sub Main()
Call OptionsMenu ' your make popup routine
Do
UserForm1.Show
If gblUF2 Then
UserForm2.Show ' your frm_POC_Info
gblUF2 = 0
Else
Exit Do
End If
Loop
End Sub

Public Sub POC_Info()
' Don't show from here.
' Flag gblUF2 for Main to show.
gblUF2 = 1
UserForm1.Hide
End Sub

Dale wrote:
>I've added a commandbar (see code below) to my userform, which pops up
>another userform. The first time I open this command bar and click on the
>POC Info button, it opens the second form properly, but when I select click
>on the label that pops this menu up a second time, there is a check in front
>of the POC Info option, and clicking on it does nothing.
>
>Any ideas what I am doing wrong?
>
>Sub OptionsMenu()
>
> Dim CmdBar As Office.CommandBar
> Dim ctrl As Office.CommandBarControl
>
> On Error Resume Next
> Application.CommandBars("MyOptions").Delete
> On Error GoTo 0
>
> Set CmdBar = Application.CommandBars.Add(Name:="MyOptions", _
>
>Position:=msoBarPopup, _
> temporary:=True)
>
> Set ctrl = CmdBar.Controls.Add(Type:=msoControlButton)
> With ctrl
> .Caption = "POC info"
> .OnAction = "POC_Info"
> End With
>
>End Sub
>
>Public Sub POC_Info()
>
> Userform1.Hide
> frm_POC_Info.Show
> Userform1.Show
>
>End Sub
>
>Dale



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
=?Utf-8?B?RGFsZSBGeWU=?=
Guest
Posts: n/a
 
      25th Oct 2007
Dave,

I think it had to do with the fact that in the OnAction code, I was hiding
the current form, then eventually showing it again (but as modal). This was
preventing the commandbar menu from completing its processing. I could tell
this because other command buttons on the menu worked properly (I would
click, it would do something, and when I opened the menu again, the item
would not have a check next to it (msoButtonDown)). When I changed it to
show the form as non-modal (Show 0), it worked properly.

Dale

--
Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.


"Dave D-C" wrote:

> Dale,
> I've had that too. I can't explain why your setup doesn't work,
> but this does.
>
> Dim gblUF2% ' a global variable
>
> Sub Main()
> Call OptionsMenu ' your make popup routine
> Do
> UserForm1.Show
> If gblUF2 Then
> UserForm2.Show ' your frm_POC_Info
> gblUF2 = 0
> Else
> Exit Do
> End If
> Loop
> End Sub
>
> Public Sub POC_Info()
> ' Don't show from here.
> ' Flag gblUF2 for Main to show.
> gblUF2 = 1
> UserForm1.Hide
> End Sub
>
> Dale wrote:
> >I've added a commandbar (see code below) to my userform, which pops up
> >another userform. The first time I open this command bar and click on the
> >POC Info button, it opens the second form properly, but when I select click
> >on the label that pops this menu up a second time, there is a check in front
> >of the POC Info option, and clicking on it does nothing.
> >
> >Any ideas what I am doing wrong?
> >
> >Sub OptionsMenu()
> >
> > Dim CmdBar As Office.CommandBar
> > Dim ctrl As Office.CommandBarControl
> >
> > On Error Resume Next
> > Application.CommandBars("MyOptions").Delete
> > On Error GoTo 0
> >
> > Set CmdBar = Application.CommandBars.Add(Name:="MyOptions", _
> >
> >Position:=msoBarPopup, _
> > temporary:=True)
> >
> > Set ctrl = CmdBar.Controls.Add(Type:=msoControlButton)
> > With ctrl
> > .Caption = "POC info"
> > .OnAction = "POC_Info"
> > End With
> >
> >End Sub
> >
> >Public Sub POC_Info()
> >
> > Userform1.Hide
> > frm_POC_Info.Show
> > Userform1.Show
> >
> >End Sub
> >
> >Dale

>
>
> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
> ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
>

 
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
Sort code doesn't work on first pass, works on second standard_guy Microsoft Excel Programming 1 16th Mar 2010 02:59 PM
commandbar control works on some computers, not others josh Microsoft Excel Programming 1 22nd Jan 2010 08:58 PM
Custom commandbar (1 works, 1 doesn't) Dale Fye Microsoft Excel Programming 6 4th Dec 2007 01:14 PM
diferent language windows, same pass, works? =?Utf-8?B?WWFt?= Windows Vista General Discussion 2 16th Apr 2007 10:30 AM
Office code works in Access, not in Outlook : re CommandBar Composer Microsoft Outlook VBA Programming 2 5th Apr 2005 11:00 PM


Features
 

Advertising
 

Newsgroups
 


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