removing macros / excel 2003

H

h.

I have a large workbook with multiple sheets in it. With the help of many
macros, it automates certain tasks and leaves a finally workbook with a few
sheets (a kind of report).

I now need a way to remove all macros from this final workbook in one,
quick, go. Removing them one by one is taking to much time.
The macros are in some 10 modules.

Hans
 
H

h.

I always use my sendmail add-in to send a copy without macro's to myself

Ron,

I tried your add in with succes. Thx very much!!!

But it is wanting to send the workbook AFTER it safes a copy to my harddisk.
With the saving to my harddisk, my needs are fullfilled. So I would need you
add-in without the email part .. ;-)

I have many hundreds of workbooks a month to send. The receiver would kill
me if I did send every workbook in a separate email. So saving them to a
directory and later send them in one go in a zipfile, is much easier for me.

It would also be nice if I could change the standard way of 'sending' to
'workbook (special)' instead of the option 'workbook' that is on top of your
list now. This means that I have to choose the second option from your list
by hand every time.

Any ideas?

Hans
 
R

Ron de Bruin

Hi h.
Maybe a code example is better for you

Do you want a macro that save the complete activeworkbook without the code.
Or only a few sheets ?
 
H

h.

I have many hundreds of workbooks a month to send
Maybe a code example is better for you

Do you want a macro that save the complete activeworkbook without the
code.
Or only a few sheets ?

All of the workbooks consist of 2, 3 or 4 sheets. And I need all sheets in
the workbook. But all the code has to be removed from the workbook.

Hans
 
H

h.

Ron,

Forgot...
It would also be handy if the workbook without the code is automatically
safed in the same spot as the original. And with the same name, but with a
"01" at the back of the original name attached. It is a lot of work when
going through many workbooks and enter all new names by hand.

Hans
 
R

Ron de Bruin

Hi Hans

Copy this macro in your personal.xls
http://www.rondebruin.nl/personal.htm

It will create a copy of the activeworkbook and save it with a date time stamp in the same folder
I have many hundreds of workbooks a month
If you want to do all workbooks in one go and all the files are in one folder then
we can create a copy of the folder with code and loop through them.

But test this example first

Sub Save_Workbook_No_Code()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String

Set wb1 = ActiveWorkbook

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

TempFilePath = wb1.Path & "\"
TempFileName = wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)

With wb2
If .VBProject.Protection = 0 Then
DeleteAllVBA wb2
Else
MsgBox "Sorry can't delete the VBA code because the project is protected.", _
, "Error"
End If

.Close SaveChanges:=True
End With

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Public Sub DeleteAllVBA(mybook As Workbook)
Dim VBComp As Object
Dim VBComps As Object
Set VBComps = mybook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case 1, 3, _
2
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
End Sub
 
H

h.

Ron,

I gonna be at my work on monday again. And I hope I am well enough with
macros to get the tests done like you suggest. Will contact you here again
on monday or tuesday when I did some tests.... ok?

Thx again fot the kind help!

Hans
 
H

h.

Ron, I wont make it this week to work on this, but I will come back to you
on this for sure!
For now I have another urgent excel question that i posted in another
message in this group. Maybe you can help with that first ;-)

Hans
 
Top