select excel file picker to store file in a selected folder

  • Hi all,


    I have some code to upload some files into a folder. Once I press a button , I get the file picker with a folder path already in it.
    The problem is that people started to use excel 2007 and now my code is not workig because of the change in excel 2007 and up.


    I found the below code for excel 2007:

    Code
    Dim f    As Object 
    Set f = Application.FileDialog(3) 
    f.AllowMultiSelect = True 
    f.Show 
    
    
    MsgBox "file choosen = " & f.SelectedItems.Count


    How can I adjust the below to work in 2007? (I have some code that will check first the version of excel, and then depending on that, it will use one code or the other).

    Code
    Dim fd As FileDialog  Set fd = Application.FileDialog(msoFileDialogFilePicker)
        fd.InitialFileName = "C:\Files\Current Evidence"
        fd.Show


    Greetings.

  • Re: select excel file picker to store file in a selected folder


    It seems to work just fine in 2007 and later versions.

    • Displays the File picker.
    • The specified InitialFileName (Directory is shown)
    • Allows selection of multiple files
    • Reports the number of selected files when closed.



    What exactly is the issue?

  • Re: select excel file picker to store file in a selected folder


    Hi Cytop,


    The first code is for 2007, I found it in google, but I have no clue how to pass the folder path where I want to move the files in.
    The second part is what I had working in excel 2003, but people could not get it to work in 2007.


    The whole setup is like this:


    Excel userform pops up, people select the type of ducments they want to add as a proof, then when they click the submit button, email is created and the filepicker pops up so they can drag the files directly into the folder. Maybe it is kind of akward, but the users don't have look for the folder path.


    Greetings.

  • Re: select excel file picker to store file in a selected folder


    Am confused.


    Both set of codes are identical, except one uses msoFileDialogFilePicker as the parameter the other uses 3.


    msoFileDialogFilePicker is a constant with a value of 3, so there's no difference there. The only other change is one procedure sets AllowMultiSelect, but that'd work in both codes in any case.


    Both work in 2007, 2010/13/16 as well as Excel 2002... From that, it's a safe bet to say they work in 2003 too.


    There's something left unsaid here.

  • Re: select excel file picker to store file in a selected folder


    Hi Cytop,


    Strange thing, it worked on Excel 2013 :-), I have no idea how out of the blue it worked on 2013 and on 2007 I got errors.
    I will need to check the code I have at work and compare it, maybe I just missed something else.


    Both work nice:


    I also need to double check if it is not the userform that has to code to check if at least one checkbox was checked and the month selected in a combobox, and the part that creates the email.


    I will try to post back on Monday.


    Greetings.

  • Re: select excel file picker to store file in a selected folder


    Hi Cytop,


    It was not that problem with the above, but when they use it in Excel 2003 and 2007, the references are set to Outlook 2003 or to Outlook 2007 and then the actuall error they get is the missing library.
    Is there a way of awoiding it?


    Greetings.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!