Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2007

Tip: Looking for answers? Try searching our database.

removing macros / excel 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
h. - 24 Jan 2007 15:23 GMT
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
Ron de Bruin - 24 Jan 2007 15:49 GMT
Hi h

See Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm

I always use my sendmail add-in to send a copy without macro's to myself if I want this
http://www.rondebruin.nl/mail/add-in.htm

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

>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
[quoted text clipped - 5 lines]
>
> Hans
h. - 25 Jan 2007 15:20 GMT
> I always use my sendmail add-in to send a copy without macro's to myself
> if I want this
> http://www.rondebruin.nl/mail/add-in.htm

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
Ron de Bruin - 25 Jan 2007 15:30 GMT
Hi 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 ?

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

>> I always use my sendmail add-in to send a copy without macro's to myself
>> if I want this
[quoted text clipped - 20 lines]
>
> Hans
h. - 25 Jan 2007 15:53 GMT
>>> 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. - 25 Jan 2007 16:00 GMT
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
Ron de Bruin - 25 Jan 2007 16:03 GMT
Hi Hans

OK, post a example today

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

> Ron,
>
[quoted text clipped - 5 lines]
>
> Hans
Ron de Bruin - 25 Jan 2007 16:34 GMT
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

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

> Hi Hans
>
[quoted text clipped - 9 lines]
>>
>> Hans
h. - 25 Jan 2007 16:57 GMT
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
Ron de Bruin - 25 Jan 2007 17:17 GMT
No Problem

If you need more help post back

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

> Ron,
>
[quoted text clipped - 5 lines]
>
> Hans
h. - 30 Jan 2007 15:20 GMT
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

> No Problem
>
[quoted text clipped - 9 lines]
>>
>> Hans
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.