Browse for a file on a network

Posted on 2003-11-21
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!
Question by:Ice123
LVL 43

Expert Comment

Comment Utility
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.

Brainbench MVP for Visual Basic

Expert Comment

Comment Utility
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


Author Comment

Comment Utility
Thanks TomLaw1999 - I already have that option so any path can be entered.


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

LVL 43

Accepted Solution

TimCottee earned 30 total points
Comment Utility
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
        MsgBox "File selected was : " & .FileName
    End With
    Exit Sub
    If Err.Number = cdlCancel Then
        MsgBox "The selection process was cancelled"
        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.

Expert Comment

Comment Utility

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now