Consulting

Results 1 to 4 of 4

Thread: Run Once @initial Startup

  1. #1

    Run Once @initial Startup

    i have a workbook that needs to call on other workboooks. when the program starts up for the very 1st time it doesn't know where to look for these sheets so the user has to choose the path through a "browse for folder" dialog box via windows' API.

    but how do i make the program run this only once and then have the file path written to the code so next time it starts up it knows where to look for the files? and if it can't find the files, then it prompts the user again.

    because, with this project, i'm not there to set it up for the user. i don't know where they will place the files. and it's unreasonable for them to go into the code to change the file path or have a dialog box pop out asking for the file everytime he/she uses it.

    with this @1st startup routine, the user can change directories all he wants and the program will never get lost.

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    You can either use code (SaveSetting) to write it to the registry, or simply write it to a cell in a worksheet in your main workbook. Then at Workbook_Open you can check to see if the cell is blank and, if so, pop up your browse dialog.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What happens if they move the files to another directory, you will need to re-run.

    Sounds like you need a toolbar button or something to let them go look, then they can control when it happens.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Quote Originally Posted by rory
    You can either use code (SaveSetting) to write it to the registry, or simply write it to a cell in a worksheet in your main workbook. Then at Workbook_Open you can check to see if the cell is blank and, if so, pop up your browse dialog.
    hey, that's not bad. writting to a hidden cell is actually a good idea. i'll try that.

Posting Permissions

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