Open/select multiple file from MS access
Hi,
Does anybody know what syntax to be used in opening multiple file in VBA ms access and store the file path?
Normally what I do inside MS excel vba is by using:
Code:
files = Application.GetOpenFilename("Excel Files (*.xls), *.xls", , , , True)
For i = 1 To UBound(files)
next i
I need this one coz I need to select multiple files (ex. xl,txt)
Thanks
Re: Open/select multiple file from MS access
This is how I do it.
Thread Moved
Code:
Dim strFile As String
Application.FileDialog(msoFileDialogOpen).Filters.Add "Images", "*.gif; *.jpg, *.png", 1
lret = Application.FileDialog(msoFileDialogOpen).Show
If lret = -1 Then
strFile = Application.FileDialog(msoFileDialogOpen).SelectedItems.Item(1)
End If
Re: Open/select multiple file from MS access
I just tested it, but why the vba gives me an error:
Run-time-error
Method 'FileDialog' of object '_Application' failed?
Do i need to activate something in the reference here?
Thanks
Re: Open/select multiple file from MS access
"_Application" are you using VB.NET or ??? FileDoalog is available at least back to Office XP (2002).
Re: Open/select multiple file from MS access
No. Im applying it to MS access 2003
Re: Open/select multiple file from MS access
You should have a reference preset to Office 11.0 since this is in Access 2003 but its basic Access code and shouldnt be failing.
Re: Open/select multiple file from MS access
Hi,
Yah I think I miss adding the Microsoft Office 11.0. Ithought it would work on already on Microsoft Access 11.0 library.
But anyway how can I make this code for selection of Multiple entry. I can select multiple files but the value of "lret" always = to -1?
How can I create a loop to make and run with every file I select?
Thanks in advance
Re: Open/select multiple file from MS access
Should be like...
Application.FileDialog(msoFileDialogOpen).Multiselect = True
Then iterate through the .SelectedItems collection.
Note: I am typing all this in the reply box so may be slightly off a bit.
Re: Open/select multiple file from MS access
Hi little correction. SHould be
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect
I figured it out already oepning multiple selection file.
Thanks so much!!!!