R
Ray Mills
I am dying here...I am trying to add an event to a sheet module
I tested the code below which adds an open event to ThisWorkbook module
and works great. "The CodeModule object has a method called
CreateEventProc that you can use to create an event procedure in class
module, a sheet"
but i just cant figure how change the "ThisWorkbook" to a sheet moule
Dim StartLine As Long
With ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
StartLine = .CreateEventProc("Open", "Workbook") + 1
.InsertLines StartLine, _
"Msgbox ""Hello World"",vbOkOnly"
End With
I tested the code below which adds an open event to ThisWorkbook module
and works great. "The CodeModule object has a method called
CreateEventProc that you can use to create an event procedure in class
module, a sheet"
but i just cant figure how change the "ThisWorkbook" to a sheet moule
Dim StartLine As Long
With ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
StartLine = .CreateEventProc("Open", "Workbook") + 1
.InsertLines StartLine, _
"Msgbox ""Hello World"",vbOkOnly"
End With