Removing VBA-code in THISWORKBOOK

JPDO

Board Regular
Joined
Apr 10, 2002
Messages
140
Dear All,

I have a problem to create a macro that should remove the VBA-code in THISWORKBOOK.
I already tried the information on the site of cpearson.com that handles about "Programming the Visual Basic Editor", but i can not figure out how to get it working on the object THISWORKBOOK.
I also did a search on this forum, but i did not found anything on this.
Can someone help me in this matter ?

Thanks in advance
 
I haven't solved this problem yet. It seems that it must be possible to delete vba code from a module like "ThisWorkbook" but I haven't sorted it out. When I do I will post the solution.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try that Hans W. Herber suggests:

Sub RemoveAllVBAElements()
Dim vbc As Object
Dim wks As Worksheet
Dim dlg As DialogSheet

With ActiveWorkbook.VBProject
For Each vbc In .VBComponents
Select Case vbc.Type
Case 1, 2, 3
.VBComponents.Remove vbc
Case 100
vbc.CodeModule.DeleteLines 1, vbc.CodeModule.CountOfLines
End Select
Next vbc
End With

End Sub

I had to make a new sheet to send just data containing on it to another person without any processing "know-hows". This method worked Perfectly in Excel 2007!
 
Upvote 0

Forum statistics

Threads
1,215,231
Messages
6,123,754
Members
449,119
Latest member
moudenourd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top