+ Reply to Thread
Results 1 to 8 of 8

Allow user to input directory to import from

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Unhappy Allow user to input directory to import from

    I have been using VB for just under a month and this is the first time I've been completely stuck...
    My current code goes like this

    Please Login or Register  to view this content.
    This is where I am having problems:

    With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\Grekazor player role analyser\Reserve team.csv" _

    I want to allow the user to define the directory. Maybe have something pop up where they can browse to the directory they have the "Reserve team.csv" file in. Is this possible? Thanks in advance!

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Allow user to input directory to import from

    Try this:

    Please Login or Register  to view this content.
    Good luck.

    abousetta

  3. #3
    Registered User
    Join Date
    05-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Allow user to input directory to import from

    Please Login or Register  to view this content.
    etc.

    You mean like that?

    Run time error 1004
    Application defined or object defined error

    Last edited by Grekazor; 05-13-2010 at 06:45 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Allow user to input directory to import from

    Please edit your post to add CODE tags.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Allow user to input directory to import from

    I apologize I didn't notice you are using a Private Sub. I use this method for a Sub and it works fine. Maybe try puting this in a sub and then calling the private sub?

    Sorry if I did more harm than good.

    abousetta

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Allow user to input directory to import from

    Don't you need something like
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Allow user to input directory to import from

    Quote Originally Posted by abousetta View Post
    I apologize I didn't notice you are using a Private Sub. I use this method for a Sub and it works fine. Maybe try puting this in a sub and then calling the private sub?

    Sorry if I did more harm than good.

    abousetta
    No not at all, I have backups.
    Any help is much appreciated.

    As I said, im new to VB so basically I have no idea what you just said

  8. #8
    Registered User
    Join Date
    05-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Allow user to input directory to import from

    Thank you so much both of you, especially for the quick replies.
    I have it as this now:
    Please Login or Register  to view this content.

    The only problem with this is that the user always has to select the file.
    There are actually 5 exact replicas of this formula except each one imports data from a different file (First team.csv, Reserve team.csv, U18 team.csv.......) but with a common directory. So it is actually the directory that I wish to allow the user to define. Is there a way to allow the user to define the directory just once when the workbook opens or upon clicking a "define directory" button and then just use their response that in the formula above?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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