Loading
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:

ActiveWorkbook.Save

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:

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*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!
J-M
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.

-Allen
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.
J-M

 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

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.