Microsoft KB Archive/85911

{|
 * width="100%"|

Excel: Using the OPEN.DIALOG and SAVE.DIALOG Functions

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 4.0, 4.0a, 5.0
 * Microsoft Excel for the Macintosh, versions 4.0, 5.0

-

SUMMARY
Two Microsoft Excel Add-in file functions, OPEN.DIALOG and SAVE.DIALOG (from FILEFNS.XLA), were inadvertently omitted from the &quot;Microsoft Excel Function Reference.&quot; The README.TXT file refers to On-Line Help to learn more about these functions but the reference to these functions in On-Line Help is incorrect. This article contains corrected information about these functions.

In Microsoft Excel version 5.0, there is no separate &quot;Function Reference.&quot; The OPEN.DIALOG and SAVE.DIALOG functions are no longer part of the add- ins. For information on these functions, from the Help Menu, choose Contents and then Reference Information. In the General Reference section, choose Microsoft Excel Macro Functions Contents. Now choose the Search button and type OPEN.DIALOG or SAVE.DIALOG to access the information you need.

MORE INFORMATION
OPEN.DIALOG and SAVE.DIALOG are file functions that are made available by loading FILEFNS.XLA from the Library directory, a subdirectory of the Microsoft Excel directory. In Microsoft Excel 4.0 for the Macintosh, these functions are made available by loading the File Functions add-in located in the Macro Library Folder. For more information on loading add-ins, see &quot;Managing Add-in Commands and Functions&quot; in Chapter 4 of the Microsoft Excel User's Guide 2.

OPEN.DIALOG displays the Open dialog box. This is the same dialog box that appears when you choose Open from the File menu. It returns the name of the file that is chosen. The syntax is as follows:

OPEN.DIALOG(file_filter,button_text,title,filter_index)

file_filter: A text string that determines what type of files will be displayed in the dialog box. All files will be displayed if file_filter is omitted. Below is an example of what the file_filter argument might look like to show add-in, text, and Lotus 1-2-3 files:

  text_description1, filter1, text_description2, filter2...

(for example, &quot;Add-In,*.XLA,Text,*.TXT,Lotus 1-2-3 Files,*.WK?&quot;)

In Microsoft Excel for the Macintosh, the &quot;file_filter&quot; argument is looking for a 4 character file type (as in Type & Creator). An example would be &quot;TEXT&quot; for TeachText documents. A resource editor that returns the file type like RESEDIT could give you this information.

button_text: The button_text argument is ignored under Excel for Windows. In Excel for the Macintosh, this argument is the text you want to appear on the Open Button of the dialog box.

title: In Microsoft Excel for Windows, this argument is a text string for the dialog box title. In Excel for the Macintosh, this argument is ignored.

filter_index: A numeric value representing the starting position in the file_filter list. In the sample file_filter list above, if the filter_index argument was equal to 2, the initial filter would be Text, *.TXT. If the number is outside the correct range for the given file_filter list or is omitted, the initial filter will be the first one in the list. In Excel for the Macintosh, this argument is ignored.

SAVE.DIALOG displays the Save dialog box. This is the same dialog box that appears when you choose Save from the File menu. It returns the filename entered by the user. The arguments for SAVE.DIALOG are the same with one exception. The syntax is as follows:

SAVE.DIALOG(init_filename,title,button_text,file_filter,filter_index)

init_filename: The default file name in the form of text.

Example
=OPEN.DIALOG(&quot;Add-In,*.XLA,Text,*.TXT,Lotus 1-2-3 Files,*.WK?&quot;,,

  &quot;Custom Open Dialog&quot;,2)

=SAVE.DIALOG(&quot;newfile.XLA&quot;,&quot;Custom Open Dialog&quot;,,   &quot;Add-In,*.XLA,Text,*.TXT,Lotus 1-2-3 Files,*.WK?&quot;,2)