Hi.

I have previously (Excel 2007) used the following piece of VBA code successfully. The procedure is called when ENTER is pressed (by changing the Application.OnKey property) and will under certain cirumstances activate a textbox and otherwise call a "normal" ENTER-keypress.

However, changing from Excel 2007 to Excel 2013 makes the code run into an infinte loop. It seems like disabling the OnKey event temporarily is no longer a possibility. But does anyone know why? And is there a way to fix the problem?

Sub cmdKeyEnterIsPressed()
    
    If WorkbookCheck = False Then GoTo NormalEnter
    
    If Left(ActiveSheet.CodeName, Len("OutputTemplate")) = "OutputTemplate" Then
        ActiveSheet.TextBox1.Activate
        Exit Sub
    End If
    
NormalEnter:
    Application.OnKey "~"
    SendKeys "{ENTER}", True
    Application.OnKey "~", "cmdKeyEnterIsPressed"
    
End Sub
Best regards.