Solved

Browse for a file on a network

Posted on 2003-11-21
5
311 Views
Last Modified: 2010-05-01
I have created a program that relies on the utilisation of another file. I have currently got a form that allows you so select the drive, directory and then file, using the respective VB controls and synchronisation between them. This works well, however I would like to be able to browse through the entire network stucture to select the file. Any ideas on how to do this. Im sure it's trivial, I just dont know how!
0
Comment
Question by:Ice123
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 9795924
Hi Ice123,

The simplest solution is to use the common dialog control. Add this component to your project and place an instance on the form. You can then use the .ShowOpen method to display the standard windows open file dialog and the .FileName property returns the selected file and full path.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 9796412
Tims method is the way to do it however if you would prefer to handle this programatically you can enter a path to the desired file, for example

\\Servername\c\Adirectory\Afile
0
 

Author Comment

by:Ice123
ID: 9796525
Thanks TomLaw1999 - I already have that option so any path can be entered.

TimCottee:

Can you please give me an example, I have never dealt with common dialog control before, and am a reasonably new programmer.

thanks.
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 30 total points
ID: 9796592
Ok, in your IDE, choose Project, Components; scroll down till you get to Microsoft Common Dialog Control and check the box next to it to add to your toolbox. Then place this new control on your form. In your code (perhaps for a command button) use:

Private Sub Command1_Click()
    With CommonDialog1
        On Error GoTo errHandler
        .CancelError = True
        .ShowOpen
        MsgBox "File selected was : " & .FileName
    End With
    Exit Sub
   
errHandler:
    If Err.Number = cdlCancel Then
        MsgBox "The selection process was cancelled"
    Else
        MsgBox "Another error occurred"
    End If
End Sub


This will either display the selected file, a message saying you cancelled or that a different error occurred.
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9796759
Listening.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

810 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