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()
This is the runGetPort:Application.OnKey "^+p", "runGetPort"
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.Sub runGetPort() Dim s As String s = "Get Port" Toll_RunUtility (s) End Sub
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. That is the workbook opens (which should never be visible) and the form does not appearIf Err <> 0 Then GoTo ErrM2
Best regardsSub 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
kristjan76
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks