I have three modules in a worksheet. I'm calling a Sub in Module3 which
needs to delete Module1 and Module2 then save the wookbook. The only
time it works is if I run it standalone. If it's called, the modules
aren't removed. I considered deleting all vbComponents but I need
Module3 left intact to transfer control to a new workbook. Maybe I need
to somehow transfer control to a Sub in Module3 rather than call it.
Thoughts?
The called Sub in Module3 is coded as follows:
Sub DelModules()
Dim VBComp1 As VBComponent
Dim VBComp2 As VBComponent
Set VBComp1 = ThisWorkbook.VBProject.VBComponents("Module1")
Set VBComp2 = ThisWorkbook.VBProject.VBComponents("Module2")
ThisWorkbook.VBProject.VBComponents.Remove VBComp1
ThisWorkbook.VBProject.VBComponents.Remove VBComp2
End Sub
--
BrianG
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!