I want to activate a workbook when switching from other applications. I\'m using Excel 2010.
In the ThisWorkbook object, I\'ve tried the following:
I guess after four years you won't have this question in mind still, so I just wanted to convert your comment into a complete answer, so that others have the answer a bit easier. The solution also works in Excel 2016.
Private Sub Workbook_Open()
'MsgBox "Opened and disabled"
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
'MsgBox "Activated and disabled"
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
'MsgBox "Deactivated and enabled"
Application.CellDragAndDrop = True
End Sub
Private Sub Workbook_Before_Close(Cancel As Boolean)
'MsgBox "Closed and enabled"
Application.CellDragAndDrop = True
End Sub
I posted this answer as community wiki, because you deserve the credit actually.