Make sense out of right-click class module

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
 
B

Bob Phillips

Your class module is called RightClickEventClass, but you are trying to
initiate a class called EventClass. Make them consistent.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
E

ExcelMonkey

Yup thats it. Sorry, I had multiple version of the individual files on my
desktop. Must have mixed them up and brought an earlier version in.

Thanks

EM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top