1

我像这样进入工作簿打开事件:

Private WithEvents App As Application ' For handling events

' Event handler for when THIS workbook is opened.
Private Sub Workbook_Open()
    Set App = Application ' Set App variable so we can add event handlers
    App.EnableEvents = True ' Set raise events = true.
End Sub

' Event handler to handle the event when a new workbook is open (ie. when Raven Viewer exports to a new workbook in excel
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
    Wb.Windows(1).Visible = False
End Sub

它隐藏了在此电子表格打开时打开的所有工作簿......但在短时间内,它们对用户可见。有什么办法可以防止这种情况吗?

我试图防止当前打开的工作簿失去任何焦点。

工作簿未使用 VBA 打开。

谢谢。

4

1 回答 1

0

使用 App_WindowActivate似乎对我来说效果更好,但我并不积极:

Private Sub App_WindowActivate(ByVal Wb As Workbook, ByVal Wn As Window)
If Not Wn Is ThisWorkbook.Windows(1) Then
    Application.EnableEvents = False
    Wn.Visible = False
    ThisWorkbook.Windows(1).Visible = True
    Application.EnableEvents = True
End If
End Sub
于 2013-03-05T18:33:04.053 回答