Event Handler in an add-ins not executed

Event Handler in an add-ins not executed

Post by V2FyZG » Fri, 15 Sep 2006 04:46:02


Hi,
I wrote an Excel add-ins (PrevSheet.xla) containing an event handler
associated to SheetDeactivate event. The add-ins is successfully installed.
The problem is that, when I open a new workbook the code event handler of
SheetDeactivate is not executed when I activate a new sheet. Where is the
problem? Any suggestion is appreciated.

Thanks in advance.
 
 
 

Event Handler in an add-ins not executed

Post by WEwtRGVubm » Fri, 15 Sep 2006 05:58:02

Warda,

It's difficult to say what the issue really is.

Two basic troubleshooting are:
Add a msgbox to the SheetDeactivate event with a simple message to see if it
gets executed at all (which I believe You have done already).
Make sure You refer to the active workbook / worksheet.

If the above does not gives any guideline to the issue then pls post the
relevant code.

--
With kind regards,
Dennis

 
 
 

Event Handler in an add-ins not executed

Post by V2FyZG » Sun, 17 Sep 2006 04:22:01

Thank you Dennis for your response.
The purpose of my code is to create a toolbar with a button that allows me
to come back to the last Excel sheet visited. To achieve this I use
SheetDeactivate(ByVal Sh As Object) event in order to save, in a file on the
disk, the name of the last sheet visited in the workbook.
The code associated is:

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Dim I, FileName
I = 1
FileName = "tmp:\LastSheet" ' Create file name.
Open FileName For Output As #I ' Open file.
Print #I, Sh.Name ' Write string to file.
Close #I
End Sub


This code works when it is saved as workbook. But after I saved it as an
Excel add-ins (PrevSheet.xla) and I load it using Tools | Add-Ins command,
this event handler is not triggered when I open an other workbook. I think
the problem is that my code of SheetDeactivate event is associated only to
sheets of PrevSheet.xla book, not for all workbooks I opened with Microsoft
Excel after I installed the add-ins.
How I can come over this problem?
Thank for any help.