Imansible rilevare l'evento WorkbookAddinInstall in MS Excel + VBA

Non sembra essere in grado di rilevare l'evento WorkbookAddinInstall con Excel 2013.

Ho creato un Add-in di Excel con un module di class (denominato CExcelEvents) che dispone di semplici gestori di sottorubri per un certo numero di events, come mostrato qui

 Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub Impostare XLApp = Applicazione Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub End Sub Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub End Sub Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub End Sub Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub End Sub Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookOpen (ByVal Wb come cartella di lavoro) Private WithEvents XLApp As Application Private Sub Class_Initialize() Set XLApp = Application End Sub Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook) MsgBox "NewWorkbook" & Wb.Name End Sub Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook) MsgBox "AddinInstall" End Sub Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook) MsgBox "AddinUnInstall" End Sub Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook) MsgBox "OpenWorkbook" & Wb.Name End Sub 

Quindi nel module ThisWorkbook della mia cartella addin ho

 Private ExcelEvents As CExcelEvents Private Sub Workbook_Open() Set ExcelEvents = New CExcelEvents End Sub Impostare ExcelEvents = Nuovo CExcelEvents Private ExcelEvents As CExcelEvents Private Sub Workbook_Open() Set ExcelEvents = New CExcelEvents End Sub 

Tutti questi gestori lavorano tranne XLApp_WorkbookAddinInstall .

Qualcuno può vedere quello che avrei potuto fare male?

Sembra che siano state rilevate eventuali aggiunte installate dopo l' installazione di addin, ma l'installazione iniziale non viene segnalata (ovviamente ciò che voglio).

Tuttavia, immettere i seguenti Subs nel module ThisWorkbook dell'aggiunta fornisce il comportmento necessario:

 Private Sub Workbook_AddinInstall() MsgBox "An addin is being installed" End Sub Private Sub Workbook_AddinUninstall() MsgBox "An addin is being removed" End Sub End Sub Private Sub Workbook_AddinInstall() MsgBox "An addin is being installed" End Sub Private Sub Workbook_AddinUninstall() MsgBox "An addin is being removed" End Sub