Included in the Office library of objects is the FileDialog object. The FileDialog object is essentially the standard dialog used in Office applications for opening and saving files. The dialog boxes from the FileDialog object allow users to specify the files and folders that a program should use and will return the paths of the selected files or folders. You can also use the FileDialog object to execute the associated action of the specified dialog box.
A reference must be set to the Microsoft Office object library before you can use the FileDialog object. From the VBA IDE, select Tools, References, and be sure the Check Box labeled Microsoft Office 11.0 Object Library is selected.
The FileDialog object contains two methods called Show() and Execute(). You use the Show() method to show one of four possible dialog boxes (see Table 7.1) depending on the constant passed to the FileDialog property of the Application object. The following statement shows the Open dialog.
Was this article helpful?