|
-
Oct 14th, 2008, 05:48 AM
#1
Thread Starter
Hyperactive Member
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
"Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"
-
Oct 14th, 2008, 09:27 AM
#2
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 15th, 2008, 01:16 AM
#3
Thread Starter
Hyperactive Member
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
"Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"
-
Oct 15th, 2008, 02:21 AM
#4
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).
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 15th, 2008, 02:56 AM
#5
Thread Starter
Hyperactive Member
Re: Open/select multiple file from MS access
No. Im applying it to MS access 2003
"Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"
-
Oct 15th, 2008, 10:13 AM
#6
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 15th, 2008, 10:08 PM
#7
Thread Starter
Hyperactive Member
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
"Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"
-
Oct 16th, 2008, 01:15 AM
#8
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 16th, 2008, 01:49 AM
#9
Thread Starter
Hyperactive Member
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!!!!
"Its easy to teach FAITHFUL MAN to be ABLE than ABLE MAN to be FAITHFUL"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|