J
Joe
I'm using Excel 2002 and Window 2000. I wrote an ActiveX DLL using VB 6.0 and have defined an Event in it. When I try to capture the event in Excel, sometimes it works and sometimes it doesn't
Here's the code cleaned up code
Excel
*****************************************
Option Explici
Private WithEvents cXL As CTXS.cXLLin
Private Sub cXL_userVerified(pfUserVerified As Boolean
If pfUserVerified The
cXL.Unprotec
Els
MsgBox "Please contact us for further information.", vbCritical, "Error! You are not thorized to use this application
Call ExitAp
End I
End Su
Private Sub Workbook_BeforeClose(Cancel As Boolean
On Error Resume Nex
cXL.Protec
Set cXL = Nothin
On Error GoTo
End Su
Private Sub Workbook_Open(
Set cXL = New CTXS.cXLLin
cXL.Workbook = ThisWorkboo
If cXL Is Nothing Then GoTo CTX_Workbook_BeforeClos
Exit Su
CTX_Workbook_BeforeClose
Call ExitAp
End Su
Private Sub ExitApp(
Application.Qui
End Su
*****************************************
DLL (relevant code)
Option Explici
Private m_XLWbk As Excel.Workboo
Private WithEvents f As frmSecurit
Public Event userVerified(pfUserVerified As Boolean
Public Property Let Workbook(ByVal wbk As Excel.Workbook
Set m_XLWbk = wb
With m_XLWb
.Worksheets(WKS_CTX).Visible = Tru
.Worksheets(WKS_ENABLE_MACROS).Visible = xlVeryHidde
End Wit
Call ShowSecurityFor
End Propert
Private Sub Class_Initialize(
Set f = New CTXS.frmSecurit
End Su
Private Sub Class_Terminate(
Set f = Nothin
End Su
Private Sub f_isValidUser(pfValidUser As Boolean
RaiseEvent userVerified(pfValidUser
End Su
Public Sub ShowSecurityForm(
f.Show vbModa
End Su
*****************************************
Does anyone have any ideas
TIA
Jo
Here's the code cleaned up code
Excel
*****************************************
Option Explici
Private WithEvents cXL As CTXS.cXLLin
Private Sub cXL_userVerified(pfUserVerified As Boolean
If pfUserVerified The
cXL.Unprotec
Els
MsgBox "Please contact us for further information.", vbCritical, "Error! You are not thorized to use this application
Call ExitAp
End I
End Su
Private Sub Workbook_BeforeClose(Cancel As Boolean
On Error Resume Nex
cXL.Protec
Set cXL = Nothin
On Error GoTo
End Su
Private Sub Workbook_Open(
Set cXL = New CTXS.cXLLin
cXL.Workbook = ThisWorkboo
If cXL Is Nothing Then GoTo CTX_Workbook_BeforeClos
Exit Su
CTX_Workbook_BeforeClose
Call ExitAp
End Su
Private Sub ExitApp(
Application.Qui
End Su
*****************************************
DLL (relevant code)
Option Explici
Private m_XLWbk As Excel.Workboo
Private WithEvents f As frmSecurit
Public Event userVerified(pfUserVerified As Boolean
Public Property Let Workbook(ByVal wbk As Excel.Workbook
Set m_XLWbk = wb
With m_XLWb
.Worksheets(WKS_CTX).Visible = Tru
.Worksheets(WKS_ENABLE_MACROS).Visible = xlVeryHidde
End Wit
Call ShowSecurityFor
End Propert
Private Sub Class_Initialize(
Set f = New CTXS.frmSecurit
End Su
Private Sub Class_Terminate(
Set f = Nothin
End Su
Private Sub f_isValidUser(pfValidUser As Boolean
RaiseEvent userVerified(pfValidUser
End Su
Public Sub ShowSecurityForm(
f.Show vbModa
End Su
*****************************************
Does anyone have any ideas
TIA
Jo