PC Review


Reply
Thread Tools Rate Thread

CreateEventProc

 
 
ojv
Guest
Posts: n/a
 
      2nd Jun 2009
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
 
Reply With Quote
 
 
 
 
r
Guest
Posts: n/a
 
      3rd Jun 2009
the problem is the name of variable "loc" ...
Function Loc(FileNumber As Integer) As Long
of VBA.FileSystem

you use
dim loc as long

or changes its name to the variable


regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


"ojv" wrote:

> 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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateEventProc Peres Microsoft Excel Crashes 0 9th Jun 2008 05:55 PM
createeventproc is really slow David Mueller Microsoft Access VBA Modules 0 22nd Feb 2008 08:33 PM
CreateEventProc not firing =?Utf-8?B?Q2hhZCBLdWVzdGVy?= Microsoft Access Forms 0 29th Sep 2007 03:17 AM
CreateEventProc error =?Utf-8?B?ZGNobWFu?= Microsoft Access Forms 16 22nd Feb 2006 10:28 PM
How to hide VBE - CreateEventProc sumesh Microsoft Access Form Coding 0 19th Aug 2003 05:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 AM.