ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help.. Add an event to a sheet module (https://www.excelbanter.com/excel-programming/352389-help-add-event-sheet-module.html)

Ray Mills

Help.. Add an event to a sheet module
 
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("ThisWorkboo k").CodeModule
StartLine = .CreateEventProc("Open", "Workbook") + 1
.InsertLines StartLine, _
"Msgbox ""Hello World"",vbOkOnly"
End With





All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com