Advertisement

08.02.2004 at 01:09AM PDT, ID: 21078927
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

VBA: Open File Browser to select path of multiple files
Tags: vba, file, open, access
Hello!

I need someone to help me with the code on how to open a file browser dialog box that can be used to select more than one ".xls" file. Similar to the one used in Outlook when selecting attachments that are more than one. I want to be able to get the complete path along with the filename of the selected/highlighted items and put them in a array. Any help would be great :-)

I'm using Windows XP with Access 2000 for this one.

Thanks!
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: rusco
Solution Provided By: Data-Man
Participating Experts: 3
Solution Grade: A
Views: 1072
Translate:
Loading Advertisement...
08.02.2004 at 01:56AM PDT, ID: 11691764

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.02.2004 at 07:09AM PDT, ID: 11693793

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.02.2004 at 09:50AM PDT, ID: 11695565

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.02.2004 at 12:24PM PDT, ID: 11697091

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.02.2004 at 01:16PM PDT, ID: 11697672

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.02.2004 at 09:52PM PDT, ID: 11700692

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.02.2004 at 11:44PM PDT, ID: 11701025

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 06:13AM PDT, ID: 11704015

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 06:19AM PDT, ID: 11704085

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 06:24AM PDT, ID: 11704125

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 06:47AM PDT, ID: 11704348

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 07:18AM PDT, ID: 11704730

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 07:23AM PDT, ID: 11704807

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 07:40PM PDT, ID: 11711941

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 07:43PM PDT, ID: 11711947

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 07:50PM PDT, ID: 11711966

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 10:03PM PDT, ID: 11712459

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 10:30PM PDT, ID: 11712524

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
08.03.2004 at 11:00PM PDT, ID: 11712597

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.28.2005 at 12:32AM PST, ID: 13417940

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.28.2005 at 05:45AM PST, ID: 13419376

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.28.2005 at 09:54AM PST, ID: 13421811

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.28.2005 at 10:02AM PST, ID: 13421896

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
08.02.2004 at 01:56AM PDT, ID: 11691764

Rank: Sage

If you have acccess to Excel 2002 or greater you can use the this code by setting a reference and creating an object variable within your Access 2000 code.  I made a few changes, but this is air code.  If you don't have access to Excel 2002, disregard...you may have to use an API to get the file open dialog.....Mike


Sub UseFileDialogOpen()

    Dim lngCount As Long
    Dim strFileNames() as String
    Dim objExcel As Excel.Application
    Set objExcel = new Excel.Application
    ' Open the file dialog
    With objExcel.FileDialog(msoFileDialogOpen)
        .AllowMultiSelect = True
        .Show

        ' Display paths of each file selected
        For lngCount = 1 To .SelectedItems.Count
            ReDim Preserve strFileNames(lngcount-1) 'Array starts at zero.
            strFileNames(lngCount-1) = .SelectedItems(lngCount)
        Next lngCount

    End With
    objExcel.Quit
    set objExcel = nothing
End Sub
 
08.02.2004 at 07:09AM PDT, ID: 11693793
Hi Mike,

Thanks for the code. Sorry to say that in the environment that we will be using the Access program for there is a possibility that some of the users will not have Excel 2002 installed in their system. Thanks for replying =)
 
08.02.2004 at 09:50AM PDT, ID: 11695565

Rank: Sage

Check out this link....it has the code for an API call.  API's are great....lots of code not so great, but they always work.

http://www.experts-exchange.com/Databases/MS_Access/Q_20116033.html?query=file+open+dialog+api&topics=39

Mike
 
08.02.2004 at 12:24PM PDT, ID: 11697091

Rank: Genius

Hi rusco

Here what you can do:
1- Open the Directory (not File) dialog, to select the Directory where your files are (I can provide code).
2- Once the Directory is selected, use the fso (File System Object) to add the files to a Listbox (I can provide code).
3- In the Listbox properties, set Multiple selection to Yes.
4- Now you can do your Multiple file selection.
5- Make a command button to loop throw the selected Listbox items and put them in a array (I can provide code).

If you always search from the same Directory, then You can Omit #1, and put the Directory in #2,
If you always search for xls files, then you can omit the other types from being built in the Listbox.

jaffer
 
08.02.2004 at 01:16PM PDT, ID: 11697672

Rank: Genius

Hi rusco

When you are lucky, then you are lucky :o)

1-
Make a module, call it MultipleFileSelection, and paste this code there:

Option Explicit

' 28-May-2001
' Valid in VB 6 only!
' When using the Common Dialog control to select multiple files
' from the File Open dialog box, the FileName property of the
' Common Dialog control will return both the path and names of
' the selected files. If the Common Dialog control only allows
' long file names to be selected, the path and file names are
' returned in a null character delimited format, with the path
' listed first, and the files listed subsequently
' This sample shows you how to get the path and the selected files
' Demo by Brian Matumbura
' For comments email: brianm@zncc.co.zw


Public Function GetFiles(Optional ByVal sTitle As String = "Open files...") As String
  ' sTitle: Optional Title of Dialog
  Dim sFilenames As String
  Dim cdlOpen As Object
  On Error GoTo ProcError
  ' Get the desired name using the common dialog
  Set cdlOpen = CreateObject("MSComDlg.CommonDialog")
  ' set up the file open dialog file types
  With cdlOpen
    ' setting CancelError means the control will
    ' raise an error if the user clicks Cancel
    .CancelError = True
    .Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.*.txt|INI Files (*.ini)|*.ini|Images (*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif"
    .FilterIndex = 1
    .DialogTitle = sTitle
    .MaxFileSize = &H7FFF ' 32KB filename buffer
    ' set up Common Dialog flags
    ' same as .Flags = cdlOFNHideReadOnly Or cdlOFNPathMustExist Or cdlOFNLongNames Or cdlOFNAllowMultiselect or cdlOFNExplorer
    .Flags = &H4 Or &H800 Or &H40000 Or &H200 Or &H80000
    .ShowOpen
    ' get the selected name
    sFilenames = .FileName
  End With
ProcExit:
  GetFiles = sFilenames
  Set cdlOpen = Nothing
  Exit Function
ProcError:
  If Err.Number = &H7FF3 Then Resume Next 'Cancel selected - Ignore
  MsgBox Err.Description & "(" & Err.Number & ")", vbExclamation, "Open error"
  sFilenames = ""
  Resume ProcExit
End Function


2-
Make a Form from Design view,
Make a Listbox, call it List1,
Make a Lable for the Listbox, call it Label1,
Make a command button, call it command2, and place the following code On Click of Command2:

Private Sub Command2_Click()

  Dim strFileNames() As String
  Dim i As Integer
 
  strFileNames = Split(GetFiles, Chr(0))

    If UBound(strFileNames) > 0 Then

      'Path is stored in index 0 of array files in index 1...
      Label1.Caption = "Files selected from: " & strFileNames(0)
      For i = 1 To UBound(strFileNames)
        If i = 1 Then
            AddFiles = strFileNames(0) & strFileNames(i)
        Else
            AddFiles = AddFiles & ";" & strFileNames(0) & strFileNames(i)
        End If
      Next
    Else
      AddFiles = "(No files selected)"
    End If
   
    Me.List1.RowSource = AddFiles

End Sub

--------------------------------
You can get he Path and File Name you are looking for, like this:

For i = 1 To UBound(strFileNames)
 mtFiles(i)=strFileNames(0) & strFileNames(i)
next i

This way, the array myFiles() will contain all your files.


jaffer
 
08.02.2004 at 09:52PM PDT, ID: 11700692
Hi Jaffer,

I tried using the code you gave me but I seem to be getting an "ActiveX Component can't create object(429)' error.

Hi Mike,

I like the idea of the API and tried out the code from the link you gave. Unfortunately it only can only select one file from open file browse 'dialog box'. I can't figure out yet how to change the API to make it able to select multiple files.

Thanks!

rusco
 
08.02.2004 at 11:44PM PDT, ID: 11701025

Rank: Genius

rusco

Make sure you have your reference to:

Visual Basic For Applications
Microsoft Access XX.X object Library
Microsoft Visual Basic for Applications Extensibility 5.3

To do the Reference, while in VB, Menu Bar > Tools > References.

If it doesn't work, let me know so that I can upload it to a site where you can download it.

jaffer
 
08.03.2004 at 06:13AM PDT, ID: 11704015
Hi jaffer,

I added the reference but I'm still getting the same error as before. Any suggestions?

thanks!
 
08.03.2004 at 06:19AM PDT, ID: 11704085
 
08.03.2004 at 06:24AM PDT, ID: 11704125

Rank: Genius

if you open the module, you will see this line

    .Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.*.txt|INI Files (*.ini)|*.ini|Images (*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif"

it is here where you can either Edit OR Add pointing to *.xls so that you can filter the xls files directly.

BTW, Click on the Open button, the dialog will popup, there you can select your multiple files.

I am using WinME and Access 2k

jaffer
 
08.03.2004 at 06:47AM PDT, ID: 11704348

Rank: Genius

Hi rusco

Were you able to download the file?

jaffer
 
08.03.2004 at 07:18AM PDT, ID: 11704730
Hi Jaffer!

Just downloaded it now. Will test it out and get back to you about it tomorrow morning as it's kinda late here. Thanks!

rusco
 
08.03.2004 at 07:23AM PDT, ID: 11704807

Rank: Genius

No problem
Nighty night

jaffer
 
08.03.2004 at 07:40PM PDT, ID: 11711941
Hi Jaffer!

Tried it out just now. Unfortunately it still gives me the same error as I stated above. I tried it out in two pc's (on my personal desktop and the one I use at work). Any ideas?

Thanks!

Mike,

Hi Mike! Any new developments with regards to the API? Thanks!

rusco
 
08.03.2004 at 07:43PM PDT, ID: 11711947

Rank: Sage

Add the ALLOWMULTISELECT flag to the code.  I checked it out and this flag is a constant in the code.  You should be able to add the flag.  You might have to add a loop around the code to return all selected files.

Might be worth while to do a search on google or some other site for the name of the api call and the word ALLOWMULTISELECT.

Mike
 
08.03.2004 at 07:50PM PDT, ID: 11711966
 
08.03.2004 at 10:03PM PDT, ID: 11712459
Mike,

Thanks! I the API to work properly. It's able to now select multiplefiles. Must have missed the ALLOWMULTISELECT flag when I read the API.

 
08.03.2004 at 10:30PM PDT, ID: 11712524

Rank: Sage

Glad you got it to work....using an API means the code will run on almost every machine...you don't have to worry about ocx or controls...Mike
 
08.03.2004 at 11:00PM PDT, ID: 11712597

Rank: Genius

rusco
I am sorry to hear this, as this mdb is working fine with me.
but I gues, like Mike said "API's are great....lots of code not so great, but they always work."
where as other codes depend on some installed components on the pc.

Good job Mike.

jaffer
 
02.28.2005 at 12:32AM PST, ID: 13417940
This is wonderful.

Just one little tweak required if possible.

How do I modify this code to allow the user to select one only access file (.mdb)?

...ie not multiple files and only files of type *.mdb

Cheers

Luigi
 
02.28.2005 at 05:45AM PST, ID: 13419376

Rank: Sage

Lugi,
  Just don't include the 'ALLOWMULTISELECT' flag when opening the dialog.

Mike
 
02.28.2005 at 09:54AM PST, ID: 13421811
Thanks Mike

That's all it took. I removed that flag and hey presto!

Cheers

Luigi
 
02.28.2005 at 10:02AM PST, ID: 13421896

Rank: Sage

Glad you got it to work.

Don't forget to close out the question.

Regards,
Mike

 
 
20080236-EE-VQP-29