Delete All Macros
A few years ago I needed to create a procedure which moved a sheet with macros in the sheet and saved the sheet. Only problem was that I did not want the freshly created sheet to have macros in the new workbook. So I needed to create part of the procedure which would remove all of the macros in the freshly created workbook.
The following is the procedure I came up with.
Sub DeleteAllMacros() 'Excel vba to delete all macros in new workbook.
Dim otmp As Object
Dim otmp As Object
With ActiveWorkbook.VBProject
End Sub
For Each otmp In .VBComponents
End With
If otmp.Type=100 Then
End If
Next otmp
otmp.CodeModule.DeleteLines 1, otmp.CodeModule.CountOfLines
otmp.CodeModule.CodePane.Window.Close
Else: .VBComponents.Remove otmp
otmp.CodeModule.CodePane.Window.Close
End If
The procedure seemed to work fine. I won't attach a workbook as testing it will be difficult. I would like to hear how you go with it though.