E
ExcelMonkey
Hi, I put together a right click menu based on a class module a while ago. I
saved all the individual files (module, class module etc) and have now tried
to import them into my Excel on a new laptop. I am getting erros and cannot
remember what I need to do to get the code to load properly at Excel start-up.
At start-up I get an Compile Error: User defined type not defined in
Thisworkbook module. It highlights the line: AppClass As EventClass
I have a reference to Microsoft Forms 2.0 Library.
Any ideas as to what I have missed?
The code is below:
'Thisworkbook
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
'*********************************
'Class Module called RightClickEventClass
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
'****************************************
'Regular Module called RightClickMenuCode
Option Explicit
Dim MyDataObj As New DataObject
Sub BuildCustomMenu()
'Various Code and Private Subs
End Sub
Thanks
EM
saved all the individual files (module, class module etc) and have now tried
to import them into my Excel on a new laptop. I am getting erros and cannot
remember what I need to do to get the code to load properly at Excel start-up.
At start-up I get an Compile Error: User defined type not defined in
Thisworkbook module. It highlights the line: AppClass As EventClass
I have a reference to Microsoft Forms 2.0 Library.
Any ideas as to what I have missed?
The code is below:
'Thisworkbook
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
'*********************************
'Class Module called RightClickEventClass
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
'****************************************
'Regular Module called RightClickMenuCode
Option Explicit
Dim MyDataObj As New DataObject
Sub BuildCustomMenu()
'Various Code and Private Subs
End Sub
Thanks
EM