PC Review


Reply
 
 
x taol
Guest
Posts: n/a
 
      19th Nov 2006
'event module
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Button1_Click
End Sub

'general module
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI)
As Long

Public Type POINTAPI
X As Long
Y As Long
End Type
Sub Button1_Click()
Dim mousePoint As POINTAPI
Dim z1 As CommandBarPopup, z2 As CommandBarPopup

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

Set cb = CommandBars.Add(Name:="popMnu", Position:=msoBarPopup,
MenuBar:=0, Temporary:=1)
For i = 0 To 2
Set z1 = cb.Controls.Add(msoControlPopup)
z1.Caption = VBA.Rnd * 100
For j = 0 To 2
Set z2 = z1.Controls.Add(msoControlPopup)
z2.Caption = VBA.Rnd * 50
For k = 1 To 2
Set cm = z2.Controls.Add(msoControlButton)
sr = Choose(k, "rw", "r")
cm.Caption = sr
cm.OnAction = "ho"
Next
Next
Next
GetCursorPos mousePoint
cb.ShowPopup mousePoint.X, mousePoint.Y
End Sub

Sub ho()
CommandBars.ActionControl.Parent.Caption
'the following code does not work.
'i want to get caption of the parent menu of clicked menu.
End Sub



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      19th Nov 2006
Application.CommandBars.ActionControl.Parent.Name

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"x taol" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 'event module
> Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
> Boolean)
> Button1_Click
> End Sub
>
> 'general module
> Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI)
> As Long
>
> Public Type POINTAPI
> X As Long
> Y As Long
> End Type
> Sub Button1_Click()
> Dim mousePoint As POINTAPI
> Dim z1 As CommandBarPopup, z2 As CommandBarPopup
>
> On Error Resume Next: Application.CommandBars("popMnu").Delete: On Error
> GoTo 0
>
> Set cb = CommandBars.Add(Name:="popMnu", Position:=msoBarPopup,
> MenuBar:=0, Temporary:=1)
> For i = 0 To 2
> Set z1 = cb.Controls.Add(msoControlPopup)
> z1.Caption = VBA.Rnd * 100
> For j = 0 To 2
> Set z2 = z1.Controls.Add(msoControlPopup)
> z2.Caption = VBA.Rnd * 50
> For k = 1 To 2
> Set cm = z2.Controls.Add(msoControlButton)
> sr = Choose(k, "rw", "r")
> cm.Caption = sr
> cm.OnAction = "ho"
> Next
> Next
> Next
> GetCursorPos mousePoint
> cb.ShowPopup mousePoint.X, mousePoint.Y
> End Sub
>
> Sub ho()
> CommandBars.ActionControl.Parent.Caption
> 'the following code does not work.
> 'i want to get caption of the parent menu of clicked menu.
> End Sub
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
x taol
Guest
Posts: n/a
 
      19th Nov 2006

no, no, error occur
i want to get caption of menu.


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
=?Utf-8?B?R3JlZyBXaWxzb24=?=
Guest
Posts: n/a
 
      20th Nov 2006
The background that a popup conctrol is attached to is itself a commandbar
and is the parent of the control. However, this commandbar does not have a
caption property. That's why the error. You instead want "Parent.Parent":


MsgBox CommandBars.ActionControl.Parent.Parent.Caption

Regards,
Greg

"x taol" wrote:

> 'event module
> Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
> Boolean)
> Button1_Click
> End Sub
>
> 'general module
> Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI)
> As Long
>
> Public Type POINTAPI
> X As Long
> Y As Long
> End Type
> Sub Button1_Click()
> Dim mousePoint As POINTAPI
> Dim z1 As CommandBarPopup, z2 As CommandBarPopup
>
> On Error Resume Next: Application.CommandBars("popMnu").Delete: On Error
> GoTo 0
>
> Set cb = CommandBars.Add(Name:="popMnu", Position:=msoBarPopup,
> MenuBar:=0, Temporary:=1)
> For i = 0 To 2
> Set z1 = cb.Controls.Add(msoControlPopup)
> z1.Caption = VBA.Rnd * 100
> For j = 0 To 2
> Set z2 = z1.Controls.Add(msoControlPopup)
> z2.Caption = VBA.Rnd * 50
> For k = 1 To 2
> Set cm = z2.Controls.Add(msoControlButton)
> sr = Choose(k, "rw", "r")
> cm.Caption = sr
> cm.OnAction = "ho"
> Next
> Next
> Next
> GetCursorPos mousePoint
> cb.ShowPopup mousePoint.X, mousePoint.Y
> End Sub
>
> Sub ho()
> CommandBars.ActionControl.Parent.Caption
> 'the following code does not work.
> 'i want to get caption of the parent menu of clicked menu.
> End Sub
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
x taol
Guest
Posts: n/a
 
      20th Nov 2006


thank you very much, Greg !!


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
=?Utf-8?B?R3JlZyBXaWxzb24=?=
Guest
Posts: n/a
 
      20th Nov 2006
You're more than welcome. Thanks for the feedback.

Greg

"x taol" wrote:

>
>
> thank you very much, Greg !!
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
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
This should not be so difficult right?? Earl.AKA J.Alladien in access forum!! Microsoft Access 2 17th Aug 2009 02:17 PM
Why is this so difficult??? HoosierAdvisor Microsoft Outlook Contacts 4 11th May 2009 04:48 PM
oh difficult... x tomi3440@yahoo.com Microsoft Excel Programming 3 2nd Apr 2008 02:49 PM
I think this is difficult - can it be done? michael.beckinsale Microsoft Excel Programming 3 27th Jul 2007 10:38 AM
Help, I'm new at this, and I'm sure it's not difficult jennifer Microsoft Access Reports 9 13th Jul 2004 08:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 PM.