我有关于我发布的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。
感谢您的帮助。