我在这样的工作簿开放事件中挂钩:
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打开工作簿。
感谢。
答案 0 :(得分: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