Want Know class module some asks...

theozz

Active Member
Joined
Jun 11, 2007
Messages
328
Hi guys
I want some issue

I make a class module with excel application
Code:
I want

module1= dim class as class module
class module= 
1) when cell duoubleclick
2) userform.show
3) before form close input a value to cell
4) form close
next time 1-2-3-4...

but...
Code:
1) when cell duoubleclick
2) userform.show
3) before form close input a value to cell
4) form close
at this time action 4 "My__App.Class_Application= nothing"

why this problem???

wrong method use???

Just one time run and "My__App.Class_Application = nothing"

Code:
module_1

Public My__App          As New Class_Class

Sub EnableApplication()
    Set My__App.Class_Application = Application
End Sub

Sub DisableApplication()
    Set My__App = Nothing
End Sub

Public Sub On_TheAction()
    DisableApplication
    EnableApplication
End Sub


Code:
class module = Class_Class
Option Explicit

Public WithEvents Class_Application     As Application


Private Sub Class_Application_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    
    Dim lng_CodeCol     As Long
    Dim str_KRW_ETC     As String
    Dim MyTarget        As Range
    Dim FN              As WorksheetFunction
    
    Set FN = Application.WorksheetFunction
    
    
    If Target.Columns.Count > 1 Then
            GoTo MyExits
    ElseIf Target.Rows.Count > 1 Then
            GoTo MyExits
    ElseIf Target.Cells.Count > 1 Then
            GoTo MyExits
    Else
    End If
    
    If Sh.Name = "param" Then
            GoTo MyExits
    End If
    
    
    Call Auto_CodeNumber_List_Make
    
    Set MyTarget = Target.Resize(1, 1)
    
    
    lng_CodeCol = Cells(1, "P").Column
        
    
    
    If Target.Column = lng_CodeCol Or Target.Column = lng_CodeCol + 1 Then
            Cancel = True
            DoEvents
            Form_Select_StudentNames.Show
    End If

MyExits:

End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Why Use this method???

this module and class module belongs main workbook (as addin)
and doubleclick and form occurs new *.xlsx workbook
 
Upvote 0
Why don't you initialise the Class_Application variable in the class's Initialize method?
 
Upvote 0

Forum statistics

Threads
1,213,485
Messages
6,113,931
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top