#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default difficult

'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 ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default difficult

Application.CommandBars.ActionControl.Parent.Name

--

HTH

Bob Phillips

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

"x taol" wrote in message
...
'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 ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default difficult


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


*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default difficult

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 ***

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default difficult



thank you very much, Greg !!


*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default difficult

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
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
Help, too difficult for me. Menno Excel Worksheet Functions 4 January 19th 06 01:53 PM
Too difficult for me, please help. Menno Excel Worksheet Functions 3 October 7th 05 02:01 PM
Difficult but do-able? Jaydubs Excel Discussion (Misc queries) 8 October 6th 05 11:01 AM
Is this difficult??? mingolo Excel Programming 1 September 15th 05 07:03 PM
Ok I have to be difficult Dominique Feteau[_2_] Excel Programming 7 August 26th 05 05:24 PM


All times are GMT +1. The time now is 12:29 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"