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
|