PDA

View Full Version : Run Once @initial Startup



vassili
08-09-2007, 02:11 AM
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.

rory
08-09-2007, 03:12 AM
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.

Bob Phillips
08-09-2007, 03:35 AM
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.

vassili
08-09-2007, 07:15 AM
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.