Ok, I realized my wimpy VBE “Open the global add-in project component” code was not going to cut it for long. So here’s a friendlier UI version. The attachment is provided for your convenience.
You will need to modify the LastEdit function to indicate a file location conducive to your environment.
Put these subs in a form named frmVBE:
Option Explicit Option Base 1 Private Sub UserForm_Initialize() Dim arrMods() As String Dim lTotal As Long Dim strActiveProj As String Dim i As Long Dim strWorkMod As String #Const mDeveloping = False #If mDeveloping Then Dim vbComp As VBComponent Dim vbComps As VBComponents #Else Dim vbComp As Object Dim vbComps As Object #End If Documents.Open ThisDocument.FullName Set vbComps = ThisDocument.VBProject.VBComponents strActiveProj = ThisDocument.VBProject.Name lTotal = vbComps.Count lblVBEForm.Caption = " " & CStr(lTotal) & " Components in this Project: " & strActiveProj ReDim arrMods(lTotal) i = 1 strWorkMod = LastEdit() With Me .txtCurrentMod.Text = "MRU Component: " & strWorkMod For Each vbComp In vbComps arrMods(i) = vbComp.Name i = i + 1 Next WordBasic.Sortarray (arrMods()) .drpMods.List = arrMods() .drpMods.Text = strWorkMod End With Set vbComp = Nothing Set vbComps = Nothing End Sub Private Sub cmdOk_Click() Unload Me End Sub Private Sub cmdCancel_Click() End End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) Dim strWorkMod As String Select Case CloseMode Case 0 'User clicked close from the control menu. Treat this as a CANCEL! Cancel = False 'Allow form to close. Read this as DO NOT CANCEL this close event. Bye, bye Case 1 'The UNLOAD code in the OK button is attempting to execute. strWorkMod = Me.drpMods If strWorkMod = "" Then MsgBox "You did not select a module. Try again.", vbCritical + vbOKOnly, "Data Entry Error" Me.drpMods.SetFocus Cancel = True Else ThisDocument.VBProject.VBComponents(strWorkMod).Activate Call LastEdit(strWorkMod) Application.ShowVisualBasicEditor = True End If End Select End Sub Function LastEdit(Optional strLastEdit As String) As String If strLastEdit = "" Then 'Get from ini LastEdit = System.PrivateProfileString(vDrv & "VBADev.ini", "VBADev", "LastEdit") Else 'Put into ini and into var System.PrivateProfileString(vDrv & "VBADev.ini", "VBADev", "LastEdit") = strLastEdit LastEdit = strLastEdit End If End Function
Put this sub in a module and attach it to a toolbar button:
Sub OpenWorkingModForm() frmVBE.Show End Sub