我有關於我發佈的AddIn的問題。AddIn灰色背景窗口
爲了確保我可以輕鬆地將AddIn升級到所有用戶,我實現了一個在兩個單獨的AddIn上啓動時運行的自更新代碼。
裝載機的AddIn運行此子上Workbook_open
Private Sub Workbook_Open()
'''''''''''''''''''''''''''''''''''''''''''''''
' Workbook_Open
' Open the add-in and close this workbook
'''''''''''''''''''''''''''''''''''''''''''''''
Dim DateNetwork As Date
Dim DateLocal As Date
Const FilePath As String = "C:\Filepath\Add In"
On Error Resume Next
DateNetwork = FileDateTime(FilePath & "\PT Core.xlam")
DateLocal = FileDateTime(ThisWorkbook.Path & "\PT Core.xlam") 'Note: using on error resume next above means DateLocal will be 0 if there is no file, so it will always download the latest.
If DateNetwork > DateLocal Then
Workbooks("PT Core.xlam").Close savechanges:=False 'Ensure the addin has not loaded already
FileCopy FilePath & "\PT Core.xlam", ThisWorkbook.Path & "\PT Core.xlam"
End If
Workbooks.Open ThisWorkbook.Path & "\PT Core.xlam"
ThisWorkbook.Close savechanges:=False
End Sub
雖然主要的AddIn運行這段代碼在Workbook_open
Private XLApp As CExcelEvents
Private Sub Workbook_Open()
Set XLApp = New CExcelEvents
End Sub
而且CExcelEvents類
Private WithEvents App As Application
Private Sub Class_Initialize()
Set App = Excel.Application
End Sub
Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Application.Run "ContextMenu.AddToCellMenu", Target
End Sub
所有這些都允許我在應用程序級別捕獲right_click事件。
當打開一個文件時,啓動AddIn啓動的加載程序,然後啓動Main AddIn。加載器關閉,然後打開文件。 但是,AddIn會在啓動時創建一個灰色的Excel實例窗口,這會給人一種打開兩個文件的印象。當我關閉文件時,AddIn保持加載狀態,我必須手動關閉應用程序。
有什麼我做錯了嗎?我似乎無法確定爲什麼會發生這種行爲。
我已經刪除了我不使用的PERSONAL.XLSB。
感謝您的幫助。