Excel.Tips.Net ExcelTips (Menu Interface)

Saving a Workbook in a Macro

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Saving a Workbook in a Macro.

If you want to save a workbook under control of your macro, you can use the Save method. This is the same as choosing the Save command from the File menu, so it will display the Save As dialog box if the document you are saving has not been previously saved. The syntax is as follows:


If you want to save the workbook to a file with a new name, use the following basic syntax:

ActiveWorkbook.SaveAs FileName:="filename"

where filename is the full name (including a path) that you want used for the file.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3346) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Saving a Workbook in a Macro.

Related Tips:

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

JMJ    10 Nov 2014, 11:41
Thanks a lot for this nifty tip!
awyatt    09 Nov 2014, 10:13
JMJ: If it were me, I would probably copy the worksheet (within the macro) to a new, blank workbook and then save that new workbook as the CSV.

JMJ    09 Nov 2014, 06:50
Hi Allen,
I'd like to save only a part of a workbook (in fact, export it in csv), and I use:
ActiveSheet.SaveAs Filename:=SvgFile, FileFormat:=xlCSV, CreateBackup:=False, local:=False

It does work, but the darn whole workbook is thus renamed and when I close it, it is considered as a csv file, losing all the other worksheets and macros!

I solved the problem by saving it first, exporting the worksheet and closing without saving.
It's far from being light and elegant... Can you propose a better solution?

Thank you very much.


Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.