+ Reply to Thread
Results 1 to 4 of 4

VBA to prompt user to select location to save file

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2007
    Posts
    51

    VBA to prompt user to select location to save file

    Hi,

    I'm trying to figure out how to have VBA check the path before it saves and it does not match, then a pop up box opens and the user can select the drive and folder where they want the file saved.

    Right now I have the location hard coded with the path to my C drive. Now several people need to use this VBA code and I don't want them to go into the VBA to change the path.

    Any help would be greatly appreciated.

    Here is my code
    Please Login or Register  to view this content.
    Last edited by Bevg; 04-04-2019 at 04:25 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: VBA to prompt user to select location to save file

    Good morning bevg,

    It is always a good idea to post a sample workbook with your query, it makes it considerably easier for us to actually test any proposed solution before we respond.

    That having been said you could use something like as a simple first step:

    FPath = InputBox("Please enter full path name to save file", "Input required path name")

    Of course, if you are expecting others to use the spreadsheet then an element of checking would be needed to ensure path exists etc.

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  3. #3
    Registered User
    Join Date
    12-11-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: VBA to prompt user to select location to save file

    Hi,
    thank you for the suggestion, 6StringJazzer said that I needed to wrap my code in [CODE][\CODE] and therefore it can be copied. So I'm getting conflicting direction.

    Anyways, I was looking at the ENVIRON(Username or Userprofile) it seems that this will not need a check statement and will automatically select the individuals desktop. Have you ever been successful with this syntax?

    If so how did you use it

    Thanks,

    Bev

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: VBA to prompt user to select location to save file

    In Windows, the path to the desktop is:

    Environ("USERPROFILE") & "\Desktop"

    You can use this in your code above to assign to FPath.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA - Save File Location Prompt
    By moni_tm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2017, 12:36 PM
  2. Replies: 1
    Last Post: 06-20-2017, 10:28 AM
  3. [SOLVED] Macro to prompt user to select a file and the selected file should saved in location
    By logesh excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2015, 03:43 PM
  4. [SOLVED] Macro to prompt user to select date and save file
    By TheLittlePrince in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2013, 08:34 AM
  5. [SOLVED] Macro to prompt user for folder location and save acitve workbook.
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2013, 06:20 PM
  6. Macro to prompt user for file name and save in location
    By Fungijus in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-21-2011, 02:16 PM
  7. How to prompt user for location of file to reference
    By SymphonyTomorrow in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-22-2010, 01:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1