Results 1 to 7 of 7
  1. #1
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228

    Create Excel File Through File Browser

    I am trying to create the ability to basically do the same thing as when you save an excel file by using the "Save As..." function. Your default browser appears, you can select your directories and type in the file name you wish to create.



    I am trying to basically transfer a querydef to a spreadsheet, but don't want the name/location to be automatic, as numerous people will create their own files using this function.

    I have experience using Office.FileDialog but I believe that function's purpose is solely to select files, not create new paths.

    Anybody have any ideas?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I have experience using Office.FileDialog but I believe that function's purpose is solely to select files, not create new paths.
    incorrect, you have an option within filedialog to set what you want to do see this link

    https://msdn.microsoft.com/en-us/lib.../ff865284.aspx

    whilst the filedialog is active you can add new folders or navigate to an existing folder

  3. #3
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    How do I pull the file path from the filedialog after the path is chosen?

    The one way I know is to go through each selecteditem...

    Code:
    for each filenm in fd.selecteditems
         filestr = filenm
    next filenm
    Is there a more direct method?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    don't understand your question - filedialog returns the path the user has selected

    Google 'access vba filedialog' to find many links on the subject

  5. #5
    mrmmickle1's Avatar
    mrmmickle1 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    North Carolina
    Posts
    78
    This may prove useful:

    http://www.mrexcel.com/forum/microso...ions-code.html

    This is another option:

    Code:
    Function GetFolder()As String
        Dim fldr As FileDialog
        Dim sItem As String
        Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
        With fldr
            .Title ="Select a Folder"
            .AllowMultiSelect =False
            .InitialFileName = Application.DefaultFilePath
            If .Show <> -1 Then Go To NextCode
            sItem =.SelectedItems(1)
        End With
    NextCode:
        GetFolder = sItem
        Set fldr =Nothing
    End Function

  6. #6
    kdbailey is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    228
    That's what I was looking for, thanks mr mickle!

    Thanks for the assistance guys, it is much appreciated.

  7. #7
    mrmmickle1's Avatar
    mrmmickle1 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    North Carolina
    Posts
    78
    Your welcome!! Glad to help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-01-2016, 10:38 AM
  2. Replies: 2
    Last Post: 03-12-2016, 05:20 PM
  3. Need Module Coding Help - File Browser
    By kagoodwin13 in forum Modules
    Replies: 1
    Last Post: 05-02-2013, 11:08 AM
  4. Import Excel file based on a date and time in file name
    By nhylan in forum Import/Export Data
    Replies: 4
    Last Post: 04-16-2013, 03:26 PM
  5. create a button for import excel file
    By tggsun in forum Forms
    Replies: 3
    Last Post: 01-17-2012, 08:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums