Really struggling with this one. I am trying to take a workbook out of design mode when a user leaves a particular sheet. I have the co which will run from buttons taking the sheet in and out of design mode.
Now I want to fire these on worksheet activate / deactivate events. Worksheet activate is fine and enters design mode.
However, VBA has a problem coming out of design mode from code. Am I missing something. Or is there a totally different way to approach this.
Thanks D
Sub testEnter()
EnterExitDesignMode True
End Sub
Sub testExit()
EnterExitDesignMode False
End Sub
Sub EnterExitDesignMode(bEnter As Boolean)
Dim cbrs As CommandBars
Const sMsoName As String = "DesignMode"
Set cbrs = Application.CommandBars
If Not cbrs Is Nothing Then
If cbrs.GetEnabledMso(sMsoName) Then
If bEnter <> cbrs.GetPressedMso(sMsoName) Then
cbrs.ExecuteMso sMsoName
Stop
End If
End If
End If
End Sub