Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Can I add code to ThisWorkbook module with VBA extensibility?

I need to copy some event procedures from one Thisworkbook module to another
Thisworkbook module, I have some code but it crashes Excel, can someone tell
what I'm doing wrong?

filename1 = ThisWorkbook.Path & "\tempmoditerate.bas"
filename2 = ThisWorkbook.Path & "\tempmodrunsfgcalcs.bas"
filename3 = ThisWorkbook.Path & "\tempmodsfcalcs.bas"
filename4 = ThisWorkbook.Path & "\tempmain.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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Can I add code to ThisWorkbook module with VBA extensibility?


Użytkownik "mikeb" napisał w wiadomo¶ci
...
I need to copy some event procedures from one Thisworkbook module to

another
Thisworkbook module, I have some code but it crashes Excel, can someone

tell
what I'm doing wrong?

filename1 = ThisWorkbook.Path & "\tempmoditerate.bas"
filename2 = ThisWorkbook.Path & "\tempmodrunsfgcalcs.bas"
filename3 = ThisWorkbook.Path & "\tempmodsfcalcs.bas"
filename4 = ThisWorkbook.Path & "\tempmain.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

try to look he
http://www.cpearson.com/excel/vbe.htm
mcg


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Can I add code to ThisWorkbook module with VBA extensibility?

mikeb,

I tried this on one machine yesterday that had Norton Antivirus and it
caused a problem because it thought the workbook with this code had a virus
"mikeb" wrote in message
...
I need to copy some event procedures from one Thisworkbook module to
another
Thisworkbook module, I have some code but it crashes Excel, can someone
tell
what I'm doing wrong?

filename1 = ThisWorkbook.Path & "\tempmoditerate.bas"
filename2 = ThisWorkbook.Path & "\tempmodrunsfgcalcs.bas"
filename3 = ThisWorkbook.Path & "\tempmodsfcalcs.bas"
filename4 = ThisWorkbook.Path & "\tempmain.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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Can I add code to ThisWorkbook module with VBA extensibility?

(woops)

mikeb,

I tried this on one machine yesterday that had Symantec Antivirus and it
caused a problem because it thought the workbook with this code had a virus
called "Bloodhound.ExcelMacro." When I tried it on another machine, it ran,
although I only had the export Filename4 lines.

hth,

Doug

"mikeb" wrote in message
...
I need to copy some event procedures from one Thisworkbook module to
another
Thisworkbook module, I have some code but it crashes Excel, can someone
tell
what I'm doing wrong?

filename1 = ThisWorkbook.Path & "\tempmoditerate.bas"
filename2 = ThisWorkbook.Path & "\tempmodrunsfgcalcs.bas"
filename3 = ThisWorkbook.Path & "\tempmodsfcalcs.bas"
filename4 = ThisWorkbook.Path & "\tempmain.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



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
Workbook_Open in ThisWorkbook.module Bob Barnes Excel Discussion (Misc queries) 1 February 12th 08 07:52 PM
Calls from sheet module to ThisWorkbook module quartz[_2_] Excel Programming 2 June 23rd 05 03:37 PM
How to use: ThisWorkbook module RichardG Excel Programming 2 October 21st 04 12:44 AM
ThisWorkbook module question Stuart[_5_] Excel Programming 3 July 17th 04 02:32 PM


All times are GMT +1. The time now is 08:08 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"