Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Application Event in Class Module
I am trying to trigger a right click menu within an XLA file. My code in my
class module is as follows below. My class module is named "EventClass". I can't seem to get the menu to trigger of the right click. The subs that get called are in a regular module. And I currently do not have any code at all in my ThisWorkbook module. Thanks Option Explicit Public WithEvents App As Excel.Application Public AppClass As EventClass Private Sub Workbook_Open() Set AppClass = New EventClass Set AppClass.App = Excel.Application End Sub Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) Call DeleteCustomMenu 'remove possible duplicates Call BuildCustomMenu 'build new menu End Sub Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean) Call DeleteCustomMenu End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Application Event in Class Module
You need to separate the code.
This code goes in This Workbook (note Private AppClass not Public) Private AppClass As EventClass Private Sub Workbook_Open() Set AppClass = New EventClass Set AppClass.App = Excel.Application End Sub Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean) Call DeleteCustomMenu End Sub and this in the class module Option Explicit Public WithEvents App As Excel.Application Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) Call DeleteCustomMenu 'remove possible duplicates Call BuildCustomMenu 'build new menu End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "ExcelMonkey" wrote in message ... I am trying to trigger a right click menu within an XLA file. My code in my class module is as follows below. My class module is named "EventClass". I can't seem to get the menu to trigger of the right click. The subs that get called are in a regular module. And I currently do not have any code at all in my ThisWorkbook module. Thanks Option Explicit Public WithEvents App As Excel.Application Public AppClass As EventClass Private Sub Workbook_Open() Set AppClass = New EventClass Set AppClass.App = Excel.Application End Sub Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) Call DeleteCustomMenu 'remove possible duplicates Call BuildCustomMenu 'build new menu End Sub Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean) Call DeleteCustomMenu End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
CLASS MODULE & SIMPLE MODULE | Excel Discussion (Misc queries) | |||
Handling of event raised in other class module | Excel Programming | |||
let and get in class module | Excel Programming | |||
Variable from a sheet module in a class module in XL XP | Excel Programming |