Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
programmatically create a macro Jim Warren Excel Programming 2 March 16th 05 10:57 PM
Remove missing reference programmatically Nacho Nachev Excel Programming 1 October 4th 04 12:19 PM
How to programmatically remove an AddIn (xla) AndyB Excel Programming 1 July 6th 04 06:38 AM
Programmatically remove sharing? Anson[_2_] Excel Programming 0 June 14th 04 08:11 PM
how to add code programmatically to a macro for a button Tina Excel Programming 0 August 26th 03 03:30 AM


All times are GMT +1. The time now is 06:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"