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.
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.