Public Sub FindSelectedComponent() Dim component As VBIDE.VBComponent Set component = Application.VBE.SelectedVBComponent MsgBox component.Name End Sub