I don't know about the situation in 2007 but in earlier versions I find it's
not always possible to set a reference to the Exit Design Mode control,
depending on how and where (same or different project Design mode was
entered) the code is run.
Sometimes as soon as code starts design mode can automatically exit and the
control no longer exists, akin to the changing 'existence' of the Insert
button in different scenarios.
I think even in earlier versions it might be worth checking 'Ctrl' returns a
reference to the control. If it's Nothing, either the mere fact of running
the code exited Design Mode or Design mode was not entered in the first
place.
Alternatively -
If Application.CommandBars.FindControl(ID:=1605).State Then
Application.CommandBars.FindControl(ID:=2597).Execute
End If
plus a bit of error handling and/or attempt to first to set references to
the controls and only proceed if they are not nothing.
Regards,
Peter T