+ Reply to Thread
Results 1 to 7 of 7

Code that looks for directory then remembers the directory location after that.

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Code that looks for directory then remembers the directory location after that.

    I have code that when you run it asks you to select the file you want information pulled from and then it places it where you want it.

    Can you change it so the first time you run it it asks for the location of the file and uses it
    then after that it remembers the files location and you don't have to select it anymore it will always be in that directory once you select it (I have to choose it first because the directory is not always in the same spot to start, but after the first run it should be in the same place.

    This works as of now by selecting the file every time.



    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code that looks for directory then remembers the directory location after that.

    Just add a worksheet, name it Admin, Basic or whatever and store the selected foldername in let's say Cell A1
    The first time this cell will be empty then ask for the path, the next time, if it's not empty use the value to set the starting point.
    Hope it makes sense to you
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Code that looks for directory then remembers the directory location after that.

    Save in a custom document property:
    Please Login or Register  to view this content.
    Ben Van Johnson

  4. #4
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: Code that looks for directory then remembers the directory location after that.

    Thanks for the help. It worked like I wanted it to....the problem is someone asked for a change so now I need to modify it. The source directory that file will be in can change from time to time.
    So what we would like is i will create another button for macro but on this code for the macro i need for the user to set the source directory at the start or when it needs to be changed they can do it at anytime.
    Then the code you just gave me will utilize that source directory and you can choose the file within that directory just like it is now. Sorry for the change up but this will help others too.

    Again thanks for your reply.

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code that looks for directory then remembers the directory location after that.

    Just add a question it the source directory is not blank
    Use this folder or something like that and if the answer is no then let the user browse and select the folder and go on

  6. #6
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: Code that looks for directory then remembers the directory location after that.

    I have tried to get that to work with no luck can you help with details within the code i used from protonLeah.......thanks for your help

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Code that looks for directory then remembers the directory location after that.

    Check with @protonLeah

+ 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. Replies: 0
    Last Post: 09-05-2013, 10:00 AM
  2. Moving Files from one directory structure to another directory
    By harddd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2013, 02:39 PM
  3. [SOLVED] Buttons to prompt for directroy. Paste directory location in corresponding cell.
    By mamero in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-27-2013, 09:19 PM
  4. Macro to Move files from one directory to other directory
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2013, 07:21 AM
  5. Need VBA code to search file in directory and sub-directory and show result
    By johnchencanada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2012, 11:13 PM
  6. Reading in the files in a directory into an array, directory chosen by user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2011, 12:52 PM
  7. Look into a directory for a zip, delete, and repeat until directory is empty.
    By HandL in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2008, 09:45 AM
  8. [SOLVED] macro to move from directory to directory
    By davegb in forum Excel General
    Replies: 20
    Last Post: 02-06-2005, 04:21 PM

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