XL: Setting Default Save As to Microsoft Excel 4.0 File Format

Last reviewed: February 3, 1998
Article ID: Q125270
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows 95, version 7.0

SUMMARY

The following example allows you to save the active worksheet in a Microsoft Excel workbook to the Microsoft Excel 4.0 Worksheet file format by default. Note that this example can easily be modified to save a workbook to any desired file format by default.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

This example describes a method that allows you to save a worksheet to the Microsoft Excel 4.0 Worksheet file format by default by choosing a menu command. The example involves the following steps:
  • Creating the Procedure
  • Adding the Procedure to a Menu
  • Creating an Add-in from the Procedure

To Create the Procedure

  1. From the Insert menu, choose Macro, and then choose Module.

  2. In the new module, enter the following:

          Sub SaveAsDefault()
             ' Display the Save As Dialog box with Microsoft Excel 4.0
             ' Worksheet selected in the Save File As Type list
             ' The active sheet must be a worksheet or an error is returned
             Application.Dialogs(xlDialogSaveAs).Show ,xlExcel4
          End Sub
    
    
Note that in the above procedure, xlExcel4 is the FileFormat property for the Microsoft Excel 4.0 Worksheet file format. You can substitute any FileFormat property for this value to save a file to that specific file format by default.

For a list of the different FileFormat properties that you can use, choose the Search button in the Visual Basic Reference and type:

   FileFormat Property

To Add the Procedure to a Menu

  1. In the module that contains the SaveAsDefault procedure, choose Menu Editor from the Tools menu.

  2. From the Menu Bars list, select Worksheet.

  3. From the Menus list, select the menu that you want to add the procedure to, such as &File.

  4. From the Menu Items list, select the menu item above which you want the new menu item added. (A new menu item is added above the selected menu item.) Choose the Insert button.

  5. In the Caption box, type the text that you want to appear on the menu, such as "Save As Excel 4" (without the quotation marks).

  6. From the Macro list, select SaveAsDefault. Choose OK.

To Create the Add-in

  1. In the module that contains the SaveAsDefault procedure, choose Make Add-in from the Tools menu.

  2. In the File Name box, enter the name of the add-in, such as "XL4" (without the quotation marks).

  3. Choose OK.

NOTE: To have the menu item appear each time you start Microsoft Excel, you can copy this add-in file to the Microsoft Excel STARTUP subdirectory.

In Microsoft Excel for the Macintosh, you can copy the file to the 'Excel Startup Folder (5)' folder located in the System Folder:Preferences folder (System 7.0 or later) or the System Folder (System 6.0).

REFERENCES

For more information about the SaveAs Method, choose the Search button in the Visual Basic Reference and type:

   SaveAs Method

Keywords          : kbcode kbprg PgmHowto
Version           : WINDOWS:5.0,5.0c,7.0; MACINTOSH:5.0,5.0a,98
Platform          : MACINTOSH WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.