Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common Dialogue filter 2

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I am using this code in a common dialogue control. I want it to open up showing only .xls files. Any idea why it's not working. Thanks

Private Sub Command4_Click()
Dim strData As String
With Me.cdlg
'Initial Directory
.InitDir = "K:\"
'Dialog Title
.DialogTitle = "ESPN Transcription Documents"
'Filter File Types
.Filter = ".xls"
.ShowOpen
'Return File and Path to a Variable
strData = .FileName
End With
MsgBox "Path: " & strData
End Sub
 
The filter property takes a string comprised of two parts (separated by a pipe (|) character). The first bit is the description you see in the list of different file types. The second is the file extension(s) associated with the description.

For Excel files your filter should look something like this:

Code:
.Filter = "Microsoft Excel (*.xls)|*.xls"

Ed Metcalfe.

Please do not feed the trolls.....
 
Many thanks. How do you get the vertical bar character from the keyboard? Even with binoculars I can't find it. Thanks
 
ZOR . . .

Shift + \

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Many thanks. I kept looking at the key near escape that has three objects on it, one looking like the character but even standing on my head I could not produce the three characters. The key you have suggested has a break in the verticle line, but that seems to be the one alright. Many thanks both.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top