Hi,

I have a Userform that the user has a option of showing it with two methods.
1. From a menu, add-in that triggers ShowFrmPorts and in this case the everything works perfectly
2. With a shortkey, when the add-in is installed I have this line in Workbook_AddinInstall()
Application.OnKey "^+p", "runGetPort"
This is the runGetPort:
Sub runGetPort()
Dim s As String
    s = "Get Port"
    Toll_RunUtility (s)
End Sub
Toll_RunUtility (s) then triggers the menu function from 1. Originally the OnKey shortcut called the sub that the menu button triggers, but since that didn't work I have complicated the code so the sub with the error runs from the same call.

Finally this is the code that is not working, JUST in second case, NB I have debugged this, that is I can't see any difference in the two methods, if I use a break point in ShowFrmPorts then the shortkey works and the menu button works as well. I do not get any error, it is just like there is an hidden Exit Sub after the code
If Err <> 0 Then GoTo ErrM2
. That is the workbook opens (which should never be visible) and the form does not appear

Sub ShowFrmPorts()
Dim addinPath As String
Dim x As String
    
    Set wbActive = ActiveWorkbook
    Set rngActive = Selection
    Application.ScreenUpdating = False
    
    addinPath = ThisWorkbook.Path
    Do Until x = "\"
        x = Right(addinPath, 1)
        addinPath = Left(addinPath, Len(addinPath) - 1)
    Loop
    
    On Error Resume Next
    Set wbDB = Workbooks.Open(addinPath & "\Database\PortsDB.xlsx", False)
    If Err <> 0 Then GoTo ErrM2

    Load frmPorts
    frmPorts.Show
    
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    
    Exit Sub
ErrM2:

End Sub
Best regards
kristjan76