Setting Default Save As to Microsoft Excel 4.0 File Format

This article was previously published under Q125270
This article has been archived. It is offered "as is" and will no longer be updated.
The following example allows you to save the active worksheet in aMicrosoft Excel workbook to the Microsoft Excel 4.0 Worksheet file formatby default. Note that this example can easily be modified to save aworkbook to any desired file format by default.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. This example describes a method that allows you to save a worksheetto the Microsoft Excel 4.0 Worksheet file format by default bychoosing 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 propertyfor the Microsoft Excel 4.0 Worksheet file format. You can substituteany FileFormat property for this value to save a file to thatspecific 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 MicrosoftExcel, you can copy this add-in file to the Microsoft Excel STARTUPsubdirectory.

In Microsoft Excel for the Macintosh, you can copy the file to the 'ExcelStartup Folder (5)' folder located in the System Folder:Preferences folder(System 7.0 or later) or the System Folder (System 6.0).
For more information about the SaveAs Method, choose the Search button inthe Visual Basic Reference and type:
SaveAs Method

Article ID: 125270 - Last Review: 09/13/2013 20:18:06 - Revision: 2.3

Microsoft Excel 95 Standard Edition, Microsoft Excel 5.0c, Microsoft Excel 5.0 Standard Edition

  • kbnosurvey kbarchive kbcode kbhowto kbprogramming KB125270