CreateEventProc

O

ojv

I get an Excel runtime error executing

loc = vbc.CodeModule.CreateEventProc("Change", "Worksheet")

as below.

Application.EnableEvents = False
For Each vbc In ActiveWorkbook.VBProject.VBComponents
If vbc.name = Worksheets(1).codeName Then
loc = vbc.CodeModule.CreateEventProc("Change", "Worksheet")
vbc.CodeModule.InsertLines loc, wsChangeEvent
Exit For
End If
Next
Application.EnableEvents = True

Using the same code to insert for example an Workbook Open event procedure
works just fine. Anybody know if this is a known problem- or perhaps I am
doing something I shouldn't do ?

I'm using Excel 2002 SP3.

Regards
ojv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top