我想在从其他应用程序切换时激活工作簿。我正在使用 Excel 2010。
在 ThisWorkbook 对象中,我尝试了以下操作:
Private Sub Workbook_Activate()
MsgBox "1"
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
MsgBox "2"
End Sub
在一个类模块中,我尝试了这些:
Public WithEvents appevent As Application
Private Sub appevent_ProtectedViewWindowActivate(ByVal Pvw As ProtectedViewWindow)
MsgBox "1"
End Sub
Private Sub appevent_ProtectedViewWindowOpen(ByVal Pvw As ProtectedViewWindow)
MsgBox "2"
End Sub
Private Sub appevent_WindowActivate(ByVal Wb As Workbook, ByVal Wn As Window)
MsgBox "3"
End Sub
Private Sub appevent_WorkbookActivate(ByVal Wb As Workbook)
MsgBox "4"
End Sub
Private Sub appevent_WorkbookDeactivate(ByVal Wb As Workbook)
MsgBox "5"
End Sub
要求是在激活此工作簿(单击或 alt-tabbed-to)时禁用 CellDragAndDrop 属性,并在此工作簿不活动时重新启用它。