LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Is it safe to add event proc. to ThisWorbook module, if yes how?

Hi, I want to transfer some event procedures from one ThisWorkbook module to
another ThisWorkbook module, is it safe to do that. If it is, what is the
best way to go about it. The code below sometimes causes Excel to crash,
what am I doing wrong? Thanks
filename1 = ThisWorkbook.Path & "\tempmoditerate.bas"
filename2 = ThisWorkbook.Path & "\tempmodrunsfgcalcs.bas"
filename3 = ThisWorkbook.Path & "\tempmodsfcalcs.bas"
filename4 = ThisWorkbook.Path & "\tempmenu.bas"


ThisWorkbook.VBProject.VBComponents("modIterate"). Export filename1
ThisWorkbook.VBProject.VBComponents("runsfgcalcs") .Export filename2
ThisWorkbook.VBProject.VBComponents("sfcalcs").Exp ort filename3
ThisWorkbook.VBProject.VBComponents("Thisworkbook" ).Export filename4


Set vbp = ActiveWorkbook.VBProject
On Error Resume Next
With vbp.VBComponents
.Remove vbp.VBComponents("moditerate")
.Import filename1
.Remove vbp.VBComponents("runsfgcalcs")
.Import filename2
.Remove vbp.VBComponents("sfcalcs")
.Import filename3

Lines = vbp.vbcomponents("thisworkbook").codemodule.counto flines
vbp.vbcomponents("thisworkbook").codemodule.delete lines 1, Lines
vbp.vbcomponents("thisworkbook").codemodule.addfro mfile filename4
vbp.vbcomponents("thisworkbook").codemodule.delete lines 1, 4
End With

Kill filename1
Kill filename2
Kill filename3
Kill filename4

 
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
Run Event Code In General Module Who I Am Excel Programming 2 April 26th 06 07:26 PM
Help.. Add an event to a sheet module Ray Mills Excel Programming 0 February 4th 06 02:17 PM
How to write a macro to import an event procedure to ThisWorbook? utdcr Excel Programming 3 February 14th 05 10:25 PM
ClearContents in event proc raises error JM[_5_] Excel Programming 0 July 1st 04 09:11 PM
Run module ON OPEN event?? MG Excel Programming 1 January 9th 04 12:31 AM


All times are GMT +1. The time now is 12:44 PM.

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"