M
mikeb
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").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
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").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