Sub testgetwbkparent()
Dim vbcomp As VBComponent
Set vbcomp = Application.VBE.ActiveCodePane.CodeModule.Parent
MsgBox GetWorkbookParent(vbcomp).Name
End Sub
Function GetWorkbookParent(vbcomp) As Workbook
Dim vbProj As vbProject
Set vbProj = vbcomp.Collection.Parent
Set GetWorkbookParent = Workbooks(Mid(vbProj.Filename, InStrRev(vbProj.Filename, "\") + 1))
End Function