M
mikeb
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").Export 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.countoflines
vbp.vbcomponents("thisworkbook").codemodule.deletelines 1, Lines
vbp.vbcomponents("thisworkbook").codemodule.addfromfile filename4
vbp.vbcomponents("thisworkbook").codemodule.deletelines 1, 4
End With
Kill filename1
Kill filename2
Kill filename3
Kill filename4
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").Export 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.countoflines
vbp.vbcomponents("thisworkbook").codemodule.deletelines 1, Lines
vbp.vbcomponents("thisworkbook").codemodule.addfromfile filename4
vbp.vbcomponents("thisworkbook").codemodule.deletelines 1, 4
End With
Kill filename1
Kill filename2
Kill filename3
Kill filename4