Insert Procedure to a Module Using VBComponents
' This program will need reference to Microsoft http://amazon.com/gp/product/0735621314 ie=UTF8&tag=vtt-20&link_code=em1&camp=212341&creative=384049&creativeASIN=0735621314&adid=bb99d65d-188c-4309-9bb3-c49757f7d101" target=_blank>Visual Basic for Extensibility Library
Dim VBP As VBProject
Dim VBC As VBComponent
Dim VBMod As CodeModule
' -----------------------------------------------------------
' Coded by Shasur for http://vbadud.blogspot.com
' -----------------------------------------------------------
Workbooks.Add
Set VBP = ActiveWorkbook.VBProject
Set VBC = VBP.VBComponents.Add(vbext_ct_StdModule)
VBC.Name = "MyMacro"
Set VBMod = VBC.CodeModule
VBMod.InsertLines 3, "Sub NewProc()" & Chr(13) & _
" Msgbox ""Welcome to VB Component Programming"" " & Chr(13) & _
"End Sub"
End Sub
Cheers