Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remove macro programmatically
Hi I have the following proceedure sat in a worksheet (sheet1):
Private Sub CommandButton1_Click() RefreshSheets End Sub I have been able to successfully get rid of the sub called 'RefreshSheets' from my module, so the code does absolutely nothing (and CommandButton1 has also been deleted programatically), but how to I get rid of this redundant code that remains. I need to remove it as the workbook still thinks it contains a macro (even tho there is no actual code within the resulting sub!) and so when I email the workbook, the recipients email client rejects it as harmful. Any help greatly appreciated. Cheers! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remove macro programmatically
From Chip Pearson's web site...
http://www.cpearson.com/excel/vbe.aspx Deleting All VBA Code In A Project This code will delete ALL VBA code in a VBProject. Sub DeleteAllVBACode() Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Dim CodeMod As VBIDE.CodeModule Set VBProj = ActiveWorkbook.VBProject For Each VBComp In VBProj.VBComponents If VBComp.Type = vbext_ct_Document Then Set CodeMod = VBComp.CodeModule With CodeMod .DeleteLines 1, .CountOfLines End With Else VBProj.VBComponents.Remove VBComp End If Next VBComp End Sub -- HTH... Jim Thomlinson " wrote: Hi I have the following proceedure sat in a worksheet (sheet1): Private Sub CommandButton1_Click() RefreshSheets End Sub I have been able to successfully get rid of the sub called 'RefreshSheets' from my module, so the code does absolutely nothing (and CommandButton1 has also been deleted programatically), but how to I get rid of this redundant code that remains. I need to remove it as the workbook still thinks it contains a macro (even tho there is no actual code within the resulting sub!) and so when I email the workbook, the recipients email client rejects it as harmful. Any help greatly appreciated. Cheers! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
programmatically create a macro | Excel Programming | |||
Remove missing reference programmatically | Excel Programming | |||
How to programmatically remove an AddIn (xla) | Excel Programming | |||
Programmatically remove sharing? | Excel Programming | |||
how to add code programmatically to a macro for a button | Excel Programming |