Chamaco
06-05-2007, 04:12 AM
Hi all !
I am getting started with VBA programming for excel. I do have some experience in mathematical C/C++ and Fortran programming, but this time I am running into trouble.
I am following O'Reilly's textbook on VBA programming (Writing excel Macros in VBA, 2nd edition) and my version of MS Excel is Excel 2003 SP2
I followed all the tutorial instruction for building the Add-In given in an example (the first book example is simply the dynamic creation of a new Menu with a Menuitem that invokes a msgbox, followed by its deletion at the closure of the workbook)
However, when I load the add-ins, the code in the Private Sub Worksheet_Open event trap does not get called when a new workbook is actually opened (and neither the code in the Private Sub Worksheet_BeforeClose is called at the closure of the workbook)
The code itself works fine because if I just run the subroutine from the debugger, it does perform the job.
The same thing happen for the Worksheet_BeforeClose routine
I tried to simplify the code in the Worksheet_Open routine by commenting out all the instructions and leaving only a "Beep" insruction, but nothing happens, e.g. if I run it from the debugger, it is just fine, but If I save the AddIn and then open/close MS EXcel Worksheet, the subroutine is never invoked (I suspect the Workbook_Open and Workbook_BeforeClose events are never caught)
Does anyone have some suggestion about what I am missing ?
Thx all !!!
I am getting started with VBA programming for excel. I do have some experience in mathematical C/C++ and Fortran programming, but this time I am running into trouble.
I am following O'Reilly's textbook on VBA programming (Writing excel Macros in VBA, 2nd edition) and my version of MS Excel is Excel 2003 SP2
I followed all the tutorial instruction for building the Add-In given in an example (the first book example is simply the dynamic creation of a new Menu with a Menuitem that invokes a msgbox, followed by its deletion at the closure of the workbook)
However, when I load the add-ins, the code in the Private Sub Worksheet_Open event trap does not get called when a new workbook is actually opened (and neither the code in the Private Sub Worksheet_BeforeClose is called at the closure of the workbook)
The code itself works fine because if I just run the subroutine from the debugger, it does perform the job.
The same thing happen for the Worksheet_BeforeClose routine
I tried to simplify the code in the Worksheet_Open routine by commenting out all the instructions and leaving only a "Beep" insruction, but nothing happens, e.g. if I run it from the debugger, it is just fine, but If I save the AddIn and then open/close MS EXcel Worksheet, the subroutine is never invoked (I suspect the Workbook_Open and Workbook_BeforeClose events are never caught)
Does anyone have some suggestion about what I am missing ?
Thx all !!!