Browse Directory and select file the easy way (1 Viewer)

mik

Lost in a VBA Jungle
Local time
Today, 09:08
Joined
Nov 16, 2004
Messages
22
Hi, Being new to VBA, the examples found so far on how to browse for a file and select it have been too complicated for me to use them, so I was wondering if there was an easy way to do it.

This is what I have managed so far, it lets you type in the path and filename;

Const BoxTitle = "Provide MSC Filename"
Dim MSCFileName As String
MSCFileName = InputBox("Enter MSC File Name including full path eg C:\Documents and Settings\Administrator\My Documents\20041103\MSC_031104_0039.dat", BoxTitle)

Answer = MsgBox("Load " + MSCFileName, _
vbOKCancel, "Confirm MSC load")
If Answer = vbCancel Then Exit Sub ' the macro ends if the user selects the CANCEL-button

FileCopy Source:=MSCFileName, destination:="C:\MSC.txt"

DoCmd.SetWarnings False

DoCmd.RunSQL "DELETE MSC_load.* FROM MSC_load"
DoCmd.TransferText acImportFixed, "MSC_ddmmyy_ssss Import Specification", "MSC_Load", "C:\MSC.txt", False, ""

[script continues on]
 

ghudson

Registered User.
Local time
Yesterday, 19:08
Joined
Jun 8, 2002
Messages
6,195
There are a lot of reasons to not do that with an input box. I am not sure if you looked at this sample db but it is not that difficult to use in your db. The extra effort you put in up front will be worth it later to you and your users.

Check out the Browse [Find a directory or file] sample.
 

Users who are viewing this thread

Top Bottom