Results 1 to 1 of 1
2003-01-14, 18:51 #1
- Join Date
- Dec 2000
- New Hampshire, USA
- Thanked 0 Times in 0 Posts
Workbook_Open does not fire in Excel 97 (97)
NOTE: This is a different issue than the one I raised in the thread "A problem using class instead of regular modules", even tho it refers to the same code.
I have a workbook that uses the ThisWorkbook object to instantiate a class
module within the workbook. There are also two regular modules. This code
does work in Excel 97, 2000 and 2002.
In preparation for moving the class module and the two regular modules to a
VB 6 compiled ActiveX DLL, I converted the two regular modules to class
modules within the workbook.
I decided to keep each class module separate to make code changes easier.
I then added a new regular module to provide Public constants that had been
in the original regular modules.
I also added wrapper functions in the new regular module that could be used
as worksheet functions using functions in the new class modules.
I added Public variables to the new module for instantiating the classes.
All 3 classes are instantiated in the Workbook Open event.
I now find that in Excel 97, the Workbook_Open event is not firing, i.e.,
the Msgbox statement is not executed and the worksheet controls do not
function. Works correctly in Excel 2000 and 2002.
Here's the code in ThisWorkbook.
clsROExcelInstance and clsRONotExcelInstance are Public variables in a
Private clsROWorkbookInstance As clsROWorkbook
Private Sub Workbook_Open()
MsgBox "Workbook_Open" ' This statement does not get executed in Excel
Set clsROWorkbookInstance = New clsROWorkbook
Set clsROWorkbookInstance.ExcelWbk = ThisWorkbook
Set clsROExcelInstance = New clsROExcel
Set clsRONotExcelInstance = New clsRONotExcel
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
Set .ExcelWbk = ThisWorkbook
If Err.Number = 0 Then
On Error GoTo 0
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)