hon,
You want the popup menu and associated routines available
for all workbooks, right?
See
http://groups.google.com/group/micr...9/5337c15304ea45c2?lnk=st&q=#5337c15304ea45c2
in which Tom O refers to
http://support.microsoft.com/kb/q158244/
which is handling application events. From that I got
the following (on XL97) which should do what you want.
In a separate workbook (Book1), add a Class module (Class1) with
Option Explicit
Public WithEvents AppEvent As Application
Private Sub AppEvent_SheetBeforeDoubleClick( _
ByVal Sh As Object, _
ByVal Target As Excel.Range, _
Cancel As Boolean)
Cancel = True
Dim CB1 As CommandBar, CBC1 As CommandBarControl
On Error Resume Next
Application.CommandBars("XYZ").Delete
On Error GoTo 0 ' restore error processing
Set CB1 = Application.CommandBars.Add("XYZ", msoBarPopup, False,
True)
Set CBC1 = CB1.Controls.Add(msoControlButton)
CBC1.Style = msoButtonCaption
CBC1.Caption = "Doit"
CBC1.OnAction = "SubDoit"
Application.CommandBars("XYZ").ShowPopup
End Sub
On the same workbook, add a Standard module (Module1) with
Option Explicit
Dim MyObject As Class1
Sub LoadEventHandler()
Set MyObject = New Class1
Set MyObject.AppEvent = Application
MsgBox "Event handler is loaded"
End Sub
Sub SubDoit() ' your stuff goes here
Dim WbName$, WsName$
WbName = ActiveSheet.Parent.Name
WsName = ActiveSheet.Name
MsgBox "You double clicked" & vbCrLf & _
WbName & vbCrLf & _
WsName & vbCrLf & _
ActiveCell.Address
Workbooks(WbName).Sheets(WsName).Cells(1, 1) = "Touch11"
Workbooks(WbName).Sheets("Sheet2").Cells(2, 2) = "Touch22"
End Sub
Then run LoadEventHandler and it's done!
You have to keep Book1 open in order to keep the event handler.
You could probably put book1 stuff in Personal.xls or an Add-In.
This is neat stuff!