Hi Will,
Set the Filter property to the following string:
"Image files (*.jpg, *.gif, *.bmp)|*.jpg, *.gif, *.bmp|All files (*.*)|*.*"
This will create two choices in the dialog: "Image files" and "All files"
Regards,
Stoil Marinov
"Stoil Marinov" <stoil_mari...@hotmail.com> wrote in message
news:2tt4plF...@uni-berlin.de...
"Stoil Marinov" <stoil_mari...@hotmail.com> wrote in message
news:2tt4plF...@uni-berlin.de...
>
"Will" <Wi...@bigpond.com> wrote in message
news:OPmed.36136$5O5....@news-server.bigpond.net.au...
The spaces are not needed after the commas but this code works for me:
With CommonDialog1
.Filter = "Image files (*.jpg,*.gif,*.bmp)|" & _
"*.jpg,*.gif,*.bmp|All files (*.*)|*.*"
.ShowOpen
End With
Without seeing your code and without any indication of what is not
working for you it's hard to say what might be wrong.
Although it is traditional to include the filter spec in the description
part of the filter, it is not actually necessary. There is really no
reason to tell the user that the filter for All Files is *.*, for
instance. It may be useful to tell them which image types you are
filtering for, but often it is just extra noise.
The text before the first | is just the text that will appear in the
File Type dropdown list, and can say anything you like. In this day and
age, you may want to include *.jpeg in your filter, since a lot of
images are now stored that way.
Private Sub Command1_Click()
With CommonDialog1
.Filter = "Ordinary Image Files|*.jpg;*.jpeg;*.bmp;*.gif|All
File Types|*.*"
.FilterIndex = 1
.ShowOpen
End With
End Sub
Picture files (*.bmp *.gif *.jpg}|*.bmp;*.gif;*.jpg|All Files|*.*
thanks to everyone who tried to help.
PS. Why isn't this in MSDN info? It would have made life much easier.
"Will" <Wi...@bigpond.com> wrote in message
news:mBced.35665$5O5....@news-server.bigpond.net.au...
>I tried all your suggestions but the only one that worked was the one with
>the semi-colons between the file types:
>
>Picture files (*.bmp *.gif *.jpg}|*.bmp;*.gif;*.jpg|All Files|*.*
>
>thanks to everyone who tried to help.
>PS. Why isn't this in MSDN info? It would have made life much easier.
>
Um.. it is.
<Quote>
Filter Property (CommonDialog)
<snip>
Remarks
A filter specifies the type of files that are displayed in the dialog
box's file list box. For example, selecting the filter *.txt displays
all text files.
Use this property to provide the user with a list of filters that can
be selected when the dialog box is displayed.
Use the pipe ( | ) symbol (ASCII 124) to separate the description and
filter values. Don't include spaces before or after the pipe symbol,
because these spaces will be displayed with the description and filter
values.
The following code shows an example of a filter that enables the user
to select text files or graphic files that include bitmaps and icons:
Text (*.txt)|*.txt|Pictures (*.bmp;*.ico)|*.bmp;*.ico
When you specify more than one filter for a dialog box, use the
FilterIndex property to determine which filter is displayed as the
default.
</Q>
--
Regards, Frank