View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
eliano[_2_] eliano[_2_] is offline
external usenet poster
 
Posts: 79
Default Insert Worksheet change procedure

On 4 Giu, 23:37, ojv wrote:
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


Hi ojv.
Probably you forget a reference to:
'Microsoft visual basic for applications extensibility 5.x
as required by Mr. "r".
For further informations, see:
http://www.cpearson.com/excel/vbe.aspx
Regards
Eliano