Solved

Show only certain extensions in Common Dialog Box

Posted on 2006-07-16
9
186 Views
Last Modified: 2010-04-30
Hi Experts.

I have a common dialog box and want to open a file but I only want to show cetain file extensions ie. .jpg etc

Many Thanks
Lee
0
Comment
Question by:ljhodgett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17116983
Private Sub Command1_Click()
CommonDialog1.Filter = ".txt|text files|.doc|Doc files"
CommonDialog1.ShowOpen
End Sub
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17117257
Hi ljhodgett
GrahamSkan post is wrong, the right code is :

Private Sub Command1_Click()
CommonDialog1.Filter = "text|*.txt files|Doc files|*.doc"
CommonDialog1.ShowOpen
End Sub
0
 
LVL 13

Accepted Solution

by:
iHadi earned 125 total points
ID: 17117258
Sorry this is the right code (printing error):

Private Sub Command1_Click()
CommonDialog1.Filter = "text files|*.txt |Doc files|*.doc"
CommonDialog1.ShowOpen
End Sub
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17117652
iHadi,

>>GrahamSkan post is wrong<<
Please read this (especially if you are not prepared to test your code):
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/help.jsp#hi64

There should not be any space after the filespec, instead of:
CommonDialog1.Filter = "text files|*.txt |Doc files|*.doc"

It should be:
CommonDialog1.Filter = "text files|*.txt|Doc files|*.doc"
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17118878
acperkins
I think as an expert, if you see a wrong solution, you should point it out so people who read this page do not get confused in trying out the solution and spend precious time in debuging it and trying to get it work. I did not use any bad or unappropriate words that could be descibed as critical comments.

As for the space issue you are right. It was a printing error, and by the way I did test the code but for the doc extention (the directory I browsed had no txt files) and I think one working extention is enough to deliver the idea. Thank you for pointing out this bug and I would not consider it criticizing!!!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17119448
>>I think as an expert, if you see a wrong solution, you should point it out so people who read this page do not get confused in trying out the solution and spend precious time in debuging it and trying to get it work<<

Perhaps.  But then at least test your solution before you post rather than posting a solution and look like an idiot when it does not do what you say it does.  Don't you agree?
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17119611
>>Please read this (especially if you are not prepared to test your code):
>>http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/help.jsp#hi64

Now this is criticizing calling me an idiot. I will not reply to it but I wish Mr. jimhorn has something to say on this.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17121956
We all make mistakes :).
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17122687
iHadi,

>>Now this is criticizing calling me an idiot.<<
I realize English may not be your first language, so please re-read what I said, I did not say you were an idiot. But feel free to post a message in Community Support if you feel my comments are in any way inappropriate.  

Also, please re-read the following from the EE Guidelines:

Test your solution when appropriate
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/help.jsp#hi66
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 64
Spell Check in VB6 13 152
Excel Automation VBA 19 116
Assign a value in Excel V-Basic 3 38
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question