Link to home
Start Free TrialLog in
Avatar of kris_sk2012
kris_sk2012Flag for United States of America

asked on

Remove VB code from saved Excel file

My excel macro is executed from command line using Workbook_Open()

At the end of the macro, the template file from where the code is running, saves a output file with date time stamp.
But the output file has the code as well, and when I open the output file, Workbook_Open() executes again with error.
How can I save the output file with out copying over the VB code/macro?
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

Which version of Excel?

If using 2007 or later the original file will be an xlsm (macro enabled). If you save as an xls it will save without the macros.

Thanks
Rob H
Avatar of kris_sk2012

ASKER

I'm using Excel 2010.
The code in the VB script that saves the new file is

 ThisWorkbook.SaveAs ThisWorkbook.Path & "\Report_" & getDateTimeStamp() & ".xls", XlFileFormat.xlExcel8

What needs to change above to save the workbook without macros or code carried over?
Hi kris,

You should try copying the workbook and then saving the copied version which doesn't include the VB code. Please refer to the last post by "johnske" here:

http://www.vbaexpress.com/forum/showthread.php?t=17337

Regards,
urzica
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works perfect!!!