Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Save without VBA code?

I have a workbook, with a bunch of VBA code that refreshes the data in the
Auto_Open event. Once opened, I would like for the end user to be able to
save an archived copy of all of the data, spreadsheets and graphs in the
workbook, but with all the VBA code removed.

Whatever method is used, I would also need to make sure they don't overwrite
the original spreadsheet as well.

Any ideas? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Save without VBA code?

Dim sName as String, bk as Workbook
Dim VBComp As Object
Dim VBComps As Object
Application.ScreenUpdating = False
sName = Left(thisworkbook.Fullname,len(thisworkbook.Fullna me)-4) & _
format(now,"yyyymmdd_hhmmss") & ".xls"
ActiveWorkbook.SaveCopyAs sName
set bk = workbooks.Open(sName)
Set VBComps = bk.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp

bk.Close SaveChanges:=True
Application.ScreenUpdating = True


Part of the code is from Chip Pearson's site:
http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy




"Joel" wrote in message
...
I have a workbook, with a bunch of VBA code that refreshes the data in

the
Auto_Open event. Once opened, I would like for the end user to be able to
save an archived copy of all of the data, spreadsheets and graphs in the
workbook, but with all the VBA code removed.

Whatever method is used, I would also need to make sure they don't

overwrite
the original spreadsheet as well.

Any ideas? Thanks!



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
Before Save code Kelly Excel Worksheet Functions 4 January 30th 08 03:57 PM
How to save my VBA-code Heine Excel Worksheet Functions 4 September 26th 06 05:46 PM
FILE 'SAVE AS' IN VBA CODE Sally Excel Discussion (Misc queries) 3 June 28th 06 03:41 PM
Macro Save As Code??? Chris Watson Excel Worksheet Functions 2 January 28th 06 10:40 AM
save without code Roman Töngi Excel Programming 7 January 10th 05 07:52 PM


All times are GMT +1. The time now is 07:03 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"