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

ID: Q125270


The information in this article applies to:
  • 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 professionals 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/overview/overview.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.


  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.


  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

Additional query words:

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


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.