How to replace vba code in one excel workbook from another workboo
Hi Christian,
this is just the opposite ... : )
but with a bit of editing... I guess it's the right way
Sub DeleteMyCode()
'On Error Resume Next
Dim m_ThisWB
Set m_ThisWB =
ThisWorkbook.VBProject.VBComponents.Item(1).Collec tion("ThisWorkbook").CodeModule
m_ThisWB.deletelines 4, m_ThisWB.countoflines
m_ThisWB.deletelines 2
DeleteComponent "Mod1"
DeleteComponent "Mod2"
DeleteComponent "Class1"
ThisWorkbook.Save
End Sub
Sub DeleteComponent(sz_CompName As String)
Dim vbc
Set vbc = ThisWorkbook.VBProject.VBComponents.Item(sz_CompNa me)
ThisWorkbook.VBProject.VBComponents.Remove vbc
End Sub
|