View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Loomis Ken Loomis is offline
external usenet poster
 
Posts: 143
Default Deleting Code in 'ThisWorkbook'

After creating a report, I use the following to delete all the code in the
main module before passing it along:

Sub DeleteAllCodeInModule()

Dim VBCodeMod As CodeModule
Dim StartLine As Long
Dim HowManyLines As Long

Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Module3").Cod eModule
With VBCodeMod
StartLine = 1
HowManyLines = .CountOfLines
.DeleteLines StartLine, HowManyLines
End With

End Sub





Now I realize I need to also delete all the code that executes when the
workbook is first opened. How can I modify the code above to delete the
lines of code in ThisWorkbook?