Pages

Saturday, December 31, 2011

Show the file picker dialog box and save the path of file

If you want open the file picker dialog box and then save the path of the file for further use.

Here is the code-



'tools->refrence-> micrososft office object library
Sub file_picker_in_access_vba()
Dim flname As String
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
' add filter on the basis of file type
.Filters.Add "Access Databases", "*.mdb; *.accdb"
'start up folder
.InitialFileName = "c:\"
.Show
End With
On Error Resume Next
flname = Application.FileDialog(msoFileDialogFilePicker).SelectedItems(1)
If flname = "" Then
MsgBox "File Not Selected"
Else
MsgBox flname
End If
End Sub

No comments:

Post a Comment