JeanRage ,
Hello, I think that you are correct and that I will need to use what you suggested, here is what I have so far.
Sub CreateEventProcedure(foldername)
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Set VBProj = Windows(foldername & ".xls").VBProject
Set VBComp = VBProj.VBComponents("ThisWorkbook")
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = .CreateEventProc("Open", "Workbook")
LineNum = LineNum + 1
.InsertLines LineNum, Sheets("CONFIG").Visible = False
End With
End Sub
I have not tried it yet does this look correct?
The
Set VBComp = VBProj.VBComponents("ThisWorkbook")
part in is one part I am not sure about. Does the line
Set VBProj = Windows(foldername & ".xls").VBProject
act like the line
Windows(foldername & ".xls").activale
Bookmarks