Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- Public WithEvents appevent As Application
- Dim ret As String
- Private Sub appevent_WorkbookActivate(ByVal wb As Workbook)
- Call ToggleDragAndDrop(wb, ret)
- 'Comment out this line when satisfied it is working as expected
- MsgBox "Cell drag & drop enabled = " & ret
- End Sub
- Option Explicit
- Public XLEvents As New cEventClass
- Sub SetEventHandler()
- If XLEvents.appevent Is Nothing Then
- Set XLEvents.appevent = Application
- End If
- End Sub
- Sub ToggleDragAndDrop(wb As Workbook, Optional ret$)
- Application.CellDragAndDrop = (wb.Name <> ThisWorkbook.Name)
- ret = Application.CellDragAndDrop
- End Sub
- Option Explicit
- Private Sub Workbook_Open()
- 'Create the event handler when the workbook opens
- Call mod_DragDrop.SetEventHandler
- Call mod_DragDrop.ToggleDragAndDrop(Me)
- End Sub
- Private Sub Workbook_SheetActivate(ByVal Sh As Object)
- ' Additional safeguard in case state loss has killed the event handler:
- ' use some workbook-level events to re-instantiate the event handler
- Call Workbook_Open
- End Sub
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement