+ Reply to Thread
Results 1 to 6 of 6

Prompt User for Location of Files needed

  1. #1
    Registered User
    Join Date
    10-21-2008
    Location
    North Carolina
    Posts
    4

    Prompt User for Location of Files needed

    I want to create an excel file and code that asks the user for two locations of files to input, then my excel file does some comparisons and calculations of those two sets of files, and spits out a nice formatted comparison file. The part of the process I am struggling with right now is prompting the user for the two directories where the two sets of files are stored.

    When the macro starts, I want a window to pop up that is similar to the window that pops up when you click the 'Open' button except a user selects a directory instead of a file. Once the user selects the location of the first directory, a second pop up which is the same as the first pop up would ask the user to choose the directory that is used to compare against the first. Let me know if this is possible or if there is a somewhat different method that has the same functionality. Thanks!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-21-2008
    Location
    North Carolina
    Posts
    4
    Thank you for your help. After changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    I tried to run your code and received the following error: "Compile Error: Label not defined" regarding the line of code
    Please Login or Register  to view this content.
    I am not sure why this error occured and if this allows the user to select a directory.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Sorry, I didn't copy all the code
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-21-2008
    Location
    North Carolina
    Posts
    4
    Thanks. Is there a way to have the user select a directory as opposed to a file in a directory?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    First you need to set a reference to the "Microsoft Shell Controls And Automation" object library. In the VBA Editor, go to the Tools menu, choose References, and scroll down to this item and put a check next to it.
    Then, copy the following code to a standard code module:
    Please Login or Register  to view this content.
    You can the call the BrowseFolder function with the following code:
    Please Login or Register  to view this content.

+ 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. Macro to pull data from multiple files with user prompt
    By jsymons in forum Excel Programming / VBA / Macros
    Replies: 51
    Last Post: 01-03-2016, 07:38 AM
  2. Trying to move all xls files from one folder to another
    By oakman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2008, 10:39 AM
  3. Macro Prompt User - Save As
    By wcexmac01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2007, 09:56 AM
  4. create separate files from master
    By izza56 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-15-2007, 05:33 AM
  5. Calculate by Groups of 4
    By SOCMentor in forum Excel General
    Replies: 4
    Last Post: 09-29-2006, 10:37 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