Microsoft Office Tutorials and References
In Depth Information
In the following example, The Garden Supply Company has a list of pictures used in their
spring catalog. You have been asked to create a worksheet that allows the user to choose the
images and insert a preview into the worksheet.
Important The following two procedures assume there is a worksheet named
ImagePreview in the active workbook.
Private Sub cmdGetFile_Click()
Dim FD As FileDialog
Dim FFs As FileDialogFilters
Dim strFileName As String
On Error GoTo Problem
Set FD = Application.FileDialog(msoFileDialogOpen)
Set FFs = .Filters
.Add “Pictures", “*.jpg"
If .Show = False Then Exit Sub
MsgBox “You have not selected a valid picture."
The FileDialog property of the Application object returns a reference to the Office FileDialogs
object. Table 13-5 lists the msofileDialogType constants available to specify the type of dialog.
Table 13-5. List of Dialog Types and Their Values