LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Get line no from right click menu ("Cell")

Hi Dave.

Thanks, very usefull.
--
Best regards
Jorgen Bondesen


"Dave Peterson" skrev i en meddelelse
...
I'm not sure what you're doing where you'd need that many choices inside
the rightclick menu.

Maybe you could use the activecell.row or the row with the number of rows
in the first area of the selection????

But since you're using the .tag property, you could call the same RunMe
procedure and just decide based on that .tag of the button you clicked.

I don't know what data() does, so I just plopped in some text:

Option Explicit
Sub auto_open()

Dim lCount As Long
Dim MyList As Variant
Dim lListCount As Long
Dim cBut As CommandBarButton

lListCount = 4

For lCount = 1 To lListCount
MyList = "runme " & lCount
Set cBut = Application.CommandBars("Cell").Controls _
.Add(Type:=msoControlButton, Temporary:=True)
With cBut
.Caption = MyList
.Style = msoButtonIconAndCaption ' msoButtonCaption
.FaceId = lCount + 50
'.SetFocus
.OnAction = ThisWorkbook.Name & "!RunMe"
.Tag = lCount
End With
Next lCount
End Sub

Sub RunMe()
With Application.CommandBars.ActionControl
'MsgBox .Caption & vbLf & .Tag
Select Case .Tag
Case Is <= 2
MsgBox "it's small"
Case Else
MsgBox "it's not small"
End Select
End With
End Sub

On 02/28/2011 11:22, Jorgen Bondesen wrote:
Hi NG

When I'm right clicking in a cell, I want my owen menu.
I can do this.
The menu depends on text in 5, 10 og 20 consecutive cells. I'm using the
text.

snip **** start

Dim lCount As Long
For lCount = 1 To lListCount
Dim MyList
MyList = data(lCount) '// text from cells

Dim cBut As CommandBarButton
Set cBut =
.CommandBars("Cell").Controls.Add(Type:=msoControl Button,
Temporary:=True)

With cBut
.Caption = MyList
.Style = msoButtonIconAndCaption ' msoButtonCaption
.FaceId = lCount + 50
.SetFocus
.OnAction = "RunMe"
.Tag = lCount
End With

snip **** end

When I'm clicking on e.g 3th line in right click menu ("Cell"), how can I
knew this, if I only have .OnAction = "RunMe"

If .OnAction = "RunMe_"& lCount then I must have aboute 30 macros or
trap
error, because I do not have any macro, and read trapinfo or macro name
and
number.

Perhaps and quite different approach?



--
Dave Peterson



 
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
Add "paste values" to right-click shortcut menu-how do? Excel 2010 Chet Excel Programming 1 June 27th 10 11:23 PM
Add "paste values" to right-click shortcut menu-how do? Chet Excel Programming 4 September 18th 09 05:24 PM
It's not CommandBars("Cell"), right-click menu! Tetsuya Oguma Excel Programming 1 July 4th 05 07:02 AM
save and restore "Workbook Menu Bar" & "Cell" menus Jeff Higgins Excel Programming 2 February 14th 05 01:33 AM
disable right mouse click on "Worksheet Menu Bar" Max Potters Excel Programming 2 November 6th 04 02:45 PM


All times are GMT +1. The time now is 07:11 PM.

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"