O
ojv
I get a runtime error in Excel using the following method:
Sub AddEvents()
Dim vbc As VBComponent, pos As Long, body as String
For Each vbc In ActiveWorkbook.VBProject.VBComponents
If vbc.name = Worksheets(1).codeName Then
pos = vbc.CodeModule.CreateEventProc("Change", "Worksheet")
body = wsEvent
vbc.CodeModule.InsertLines pos, body
Exit For
End If
Next
End Sub
What am i doing wrong?
Any help appreciated
ojv
Sub AddEvents()
Dim vbc As VBComponent, pos As Long, body as String
For Each vbc In ActiveWorkbook.VBProject.VBComponents
If vbc.name = Worksheets(1).codeName Then
pos = vbc.CodeModule.CreateEventProc("Change", "Worksheet")
body = wsEvent
vbc.CodeModule.InsertLines pos, body
Exit For
End If
Next
End Sub
What am i doing wrong?
Any help appreciated
ojv