Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Remove All VBA

Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then savesAS
the wb in another name. At that point, I want the same code to remove all
code from that wb and save the wb. Can that be done and how? Thanks for
your time. Otto

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Remove All VBA

See Chip's site for programmatically removing VBA from a workbook.

http://www.cpearson.com/excel/VBE.aspx


Gord Dibben MS Excel MVP


On Sun, 13 Dec 2009 12:48:30 -0500, "Otto Moehrbach"
wrote:

Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then savesAS
the wb in another name. At that point, I want the same code to remove all
code from that wb and save the wb. Can that be done and how? Thanks for
your time. Otto


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Remove All VBA

Hi,

This would after the SaveAs routine

Sub DeleteCode()
Msg = "Are you sure you want to delete Code from " & ActiveWorkbook.Name
Response = MsgBox(Msg, vbYesNo)
If Response = vbNo Then Exit Sub
On Error Resume Next
With ActiveWorkbook.VBProject
For X = .VBComponents.Count To 1 Step -1
.VBComponents.Remove .VBComponents(X)
Next X
For X = .VBComponents.Count To 1 Step -1
.VBComponents(X).CodeModule.DeleteLines _
1, .VBComponents(X).CodeModule.CountOfLines
Next X
End With
End Sub

Mike

"Otto Moehrbach" wrote:

Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then savesAS
the wb in another name. At that point, I want the same code to remove all
code from that wb and save the wb. Can that be done and how? Thanks for
your time. Otto

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Remove All VBA

Save the file as xlsx and all your code is gone

Maybe this page will help
http://www.rondebruin.nl/saveas.htm


--

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


"Otto Moehrbach" wrote in message ...
Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then savesAS
the wb in another name. At that point, I want the same code to remove all
code from that wb and save the wb. Can that be done and how? Thanks for
your time. Otto

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Remove All VBA

The learning curve for me with E2007 shows no sign of becoming less steep,
thanks for that tip.

Mike

"Ron de Bruin" wrote:

Save the file as xlsx and all your code is gone

Maybe this page will help
http://www.rondebruin.nl/saveas.htm


--

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


"Otto Moehrbach" wrote in message ...
Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then savesAS
the wb in another name. At that point, I want the same code to remove all
code from that wb and save the wb. Can that be done and how? Thanks for
your time. Otto

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Remove All VBA

Mike
Ditto. I'm old and there is no end to it. Otto

"Mike H" wrote in message
...
The learning curve for me with E2007 shows no sign of becoming less steep,
thanks for that tip.

Mike

"Ron de Bruin" wrote:

Save the file as xlsx and all your code is gone

Maybe this page will help
http://www.rondebruin.nl/saveas.htm


--

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


"Otto Moehrbach" wrote in message
...
Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then
savesAS
the wb in another name. At that point, I want the same code to remove
all
code from that wb and save the wb. Can that be done and how? Thanks
for
your time. Otto

.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Remove All VBA

Ron
I did that and the file now is an xlsx file. All the code is there and
it runs!! Did I miss something? Each time I save it, it warns me that I
will lose all my code. I click Yes and the code is still there. Otto

"Ron de Bruin" wrote in message
...
Save the file as xlsx and all your code is gone

Maybe this page will help
http://www.rondebruin.nl/saveas.htm


--

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


"Otto Moehrbach" wrote in message
...
Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then
savesAS the wb in another name. At that point, I want the same code to
remove all code from that wb and save the wb. Can that be done and how?
Thanks for your time. Otto


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Remove All VBA

Ron
After saving it as an xlsx file, I closed the file. Closed Excel.
Opened Excel and the file and the code is gone. Otto

"Ron de Bruin" wrote in message
...
Save the file as xlsx and all your code is gone

Maybe this page will help
http://www.rondebruin.nl/saveas.htm


--

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


"Otto Moehrbach" wrote in message
...
Excel 2007 Win 7 64-bit
I have a wb with VBA code that does various things. The code then
savesAS the wb in another name. At that point, I want the same code to
remove all code from that wb and save the wb. Can that be done and how?
Thanks for your time. Otto


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
how do i remove an excel link that break link won't remove brosull Excel Worksheet Functions 1 June 29th 09 06:34 PM
Remove add-in - also remove toolbar Flemming[_2_] Excel Programming 6 January 7th 09 01:28 PM
remove convert/extract the number from'12345.56; ie remove ' sign WAN Excel Worksheet Functions 2 January 10th 08 12:38 PM
How do I remove hyperlink if 'remove' option is disabled Vipul New Users to Excel 1 January 8th 08 02:34 PM
Is there a way to remove numbers w/o remove formulas Annette[_3_] Excel Programming 2 July 23rd 03 07:29 PM


All times are GMT +1. The time now is 07:59 PM.

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"