Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default CreateEventProc

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default CreateEventProc

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateEventProc causes crash Thomas[_22_] Excel Programming 5 January 27th 09 10:54 AM
Problem in InsertLines and CreateEventProc [email protected] Excel Programming 1 November 18th 05 12:06 PM
avoiding VBEopen when using CreateEventProc:AGAIN [email protected][_2_] Excel Programming 0 December 17th 04 07:03 PM
avoiding VBEopen when using CreateEventProc [email protected][_2_] Excel Programming 4 December 14th 04 05:40 PM
Using CreateEventProc fails when used with a Worksheet. George Doster Excel Programming 3 October 22nd 03 04:22 PM


All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"