30.04.2017 Views

4523756273

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 15: Simple Dialog Boxes<br />

245<br />

The GetOpenFilename method takes the optional arguments shown in<br />

Table 15-5.<br />

Table 15-5<br />

Argument<br />

FileFilter<br />

FilterIndex<br />

Title<br />

ButtonText<br />

MultiSelect<br />

GetOpenFilename Method Arguments<br />

What It Does<br />

Determines the types of files that appear in the dialog box (for<br />

example, *.TXT). You can specify several different filters from<br />

which the user can choose.<br />

Determines which of the file filters the dialog box displays by<br />

default.<br />

Specifies the caption for the dialog box’s title bar.<br />

Ignored (used only for the Macintosh version of Excel).<br />

If True, the user can select multiple files.<br />

A GetOpenFilename example<br />

The fileFilter argument determines what appears in the dialog box’s Files of<br />

Type drop-down list. This argument consists of pairs of file filter strings followed<br />

by the wild card file filter specification, with commas separating each<br />

part and pair. If omitted, this argument defaults to the following:<br />

All Files (*.*), *.*<br />

Notice that this string consists of two parts:<br />

All Files (*.*)<br />

and<br />

*.*<br />

The first part of this string is the text displayed in the Files of Type dropdown<br />

list. The second part determines which files the dialog box displays.<br />

For example, *.* means all files.<br />

The code in the following example brings up a dialog box that asks the user<br />

for a filename. The procedure defines five file filters. Notice that I use the<br />

VBA line continuation sequence to set up the Filter variable; doing so helps<br />

simplify this rather complicated argument.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!