From VB program programmatically insert event procedure into Excel
I have a group of Excel worksheets that contain many Visual Basic event procedures and modules. I would like to be able to update the code in these worksheet procedures and modules directly from an external Visual Basic program. In the external Visual Basic program I have a routine that defines the Excel worksheet I want to change and have had no problem in extracting or changing information in the Excel worksheet cells. In the external Visual Basic program the following is what I use to access information contained in my Excel worksheets.

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("C:\Excel\MyWorksheet.xls", , False)
Set xlSheet = xlBook.Sheets(3)

How can I Import, Remove, or Change modules or event procedures to the Excel worksheet from my external Visual Basic program? If anybody knows how to do this would you please provide me with a sample.