Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save Excel Workbook without Code

Status
Not open for further replies.

hrsnblm

Programmer
Feb 6, 2009
4
US
Hi. I have a workbook that does some data manipulation and graphing and then does a SAVEAS at the end.The problem I have is that I do not want to save the VBA code in this new workbook/file. It only supposed to be the data and graphs. How can I do this? How can I either eliminate the code before I SAVEAS, or is there an option in the SAVEAS command that allows me to not save the macros/code?

Thanks ahead of time for any and all assistance.
 



Hi,

Create a New Workbook
You must Copy each Sheet to the new workbook.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This will leave out the VBA code/macros from the new workbook?
 


Are your macros in a MODULE or in one of the Sheet Object Code Windows?

If in a MODULE, then yes. Otherwise no.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
My code is restricted to a form that occurs at start-up, and to my ThisWorkbook. There is none directly associated with the sheet(s).
 
This is difficult to implement unless the User has "Trust access to Visual Basic Project" ticked in his Excel Macro Security Settings, so something like;

Sub MyMacro

'Lots of Code

'Remove me
'error occurs if "Trust access to Visual Basic Project" is unticked
On Error GoTo SkipIt
With ActiveWorkbook.VBProject.VBComponents
'discard the macro code
.Remove .Item("ModuleName")
End With

SkipIt:

End Sub

is the best I have so far with recommendations (re small file sizes) and warnings (re security issues) to users.
 
Thanks. I will give it a try and feedback what happens.
 
Skip, sorry I had'nt seen your post before I sent mine, copying out to a new WorkBook is an obvious example. I had been concentrating on the current WorkBook.
 


No problem. There is more than one way to skin a cat! ;-0

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top