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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Dialog Box 1

Status
Not open for further replies.

Edge118

Programmer
Jun 15, 2004
104
US
In my program I want to make an open dialog box come up when the user clicks on a command button so that they can select a file that will then open.

I was looking at the MSDN documentation and found the following code, but CommonDialog1 isn't declared so it doesn't work (What should I create it as?).

Code:
Private Sub mnuFileOpen_Click ()
   ' CancelError is True.
   On Error GoTo ErrHandler
   ' Set filters.
   CommonDialog1.Filter = "All Files (*.*)|*.*|Text _
   Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
   ' Specify default filter.
   CommonDialog1.FilterIndex = 2

   ' Display the Open dialog box.
   CommonDialog1.ShowOpen 
   ' Call the open file procedure.
   OpenFile (CommonDialog1.FileName)
   Exit Sub

ErrHandler:
' User pressed Cancel button.
   Exit Sub
End Sub

Thanks for any help you can give me.

"Pin me. Perl me."

Regards,

Chris
 
In VB, press CTRL-T, in the components form, select "Microsoft Common Dialog".

Then, add the common dialog control to the form that you want to use it. This will be a "hidden" control, so that it will not appear when running the app, but you will be able to use its functionality.



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top