ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Remove VBA code (https://www.excelbanter.com/excel-programming/288608-remove-vba-code.html)

Michi[_2_]

Remove VBA code
 
Hi!
I have removed the VBA code from the workbook "Test.xls", saved and
closed. When I reopened the workbook the message "Workbook countains
macros" popped up.
I saved the workbook and reopened it again and to my surprise no macro
warning occurred. Can anyone explain that to me?

For vba code deleting I used the macro of www.cpearson.com. See the
vba code below:

Public Sub test()
ThisWorkbook.SaveAs ("Test1")
DeleteAllVBA
ThisWorkbook.Save
End Sub
Sub DeleteAllVBA()

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp

End Sub

Thanks for your help
Michi

Don Guillett[_4_]

Remove VBA code
 
You must also "remove" the macro module goto vbe by alt f11right click on
the moduleremoveNO

--
Don Guillett
SalesAid Software

"Michi" wrote in message
om...
Hi!
I have removed the VBA code from the workbook "Test.xls", saved and
closed. When I reopened the workbook the message "Workbook countains
macros" popped up.
I saved the workbook and reopened it again and to my surprise no macro
warning occurred. Can anyone explain that to me?

For vba code deleting I used the macro of
www.cpearson.com. See the
vba code below:

Public Sub test()
ThisWorkbook.SaveAs ("Test1")
DeleteAllVBA
ThisWorkbook.Save
End Sub
Sub DeleteAllVBA()

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp

End Sub

Thanks for your help
Michi




Michaela Sulzbacher

Remove VBA code
 


I guess you have not tried out the code I provided, because the modules
are also removed automatically.

Michi

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Michaela Sulzbacher

Remove VBA code
 


Please Help!!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com