Search for path in VBA code

  • Thread starter JohnG via AccessMonster.com
  • Start date
J

JohnG via AccessMonster.com

I have VBA code in an Access 2003 module that has, hard coded, a path to a
Microsoft Word template file.
The path on my C: drive has changed (the file name remains the same) .

Is there code that I can use in that VBA module to search different paths
until it finds the needed file name so that I don’t have to keep changing the
hard coded path. Maybe similar to the “*†function to search for strings.

Thanks,
JohnG
 
P

Paul Shapiro

You could write code to search the whole disk drive, but it will be very
very very slow. I would try some other approach.
1. Store the path in the database, or in the registry, and give the user a
way to update the setting.
2. Present a browse box each time to let the user select the file. Save
their selected folder and set it as the default as in #1 above. When you
open the browse box, start in the last folder they used.
3. Use a fixed folder located under the application folder, or the backend
database folder if the data is on a server. Tell the users where the file
should be located if they want it to be found.
 
J

JohnG via AccessMonster.com

Thanks Paul for your response. I had used your solution in other applications
I have written but I wanted to find out if there was some code to do it
quickly.

JohnG

Paul said:
You could write code to search the whole disk drive, but it will be very
very very slow. I would try some other approach.
1. Store the path in the database, or in the registry, and give the user a
way to update the setting.
2. Present a browse box each time to let the user select the file. Save
their selected folder and set it as the default as in #1 above. When you
open the browse box, start in the last folder they used.
3. Use a fixed folder located under the application folder, or the backend
database folder if the data is on a server. Tell the users where the file
should be located if they want it to be found.
I have VBA code in an Access 2003 module that has, hard coded, a path to a
Microsoft Word template file.
[quoted text clipped - 4 lines]
the
hard coded path. Maybe similar to the “*†function to search for strings.
 
M

Mike Painter

JohnG said:
I have VBA code in an Access 2003 module that has, hard coded, a path
to a Microsoft Word template file.
The path on my C: drive has changed (the file name remains the same) .

Is there code that I can use in that VBA module to search different
paths until it finds the needed file name so that I don't have to
keep changing the hard coded path. Maybe similar to the "*" function
to search for strings.

If this is an occasional thing, just put the path in a "company data" table
and use a dlookup to get it. I'd probably put the file name in there also so
if they change that you can just smile.
 
J

JohnG via AccessMonster.com

Thanks, Mike for your response. I have used your solution in other Access
apps but I wanted to see if there was some code to search the C: drive.

Thanks,
John

Mike said:
I have VBA code in an Access 2003 module that has, hard coded, a path
to a Microsoft Word template file.
[quoted text clipped - 4 lines]
keep changing the hard coded path. Maybe similar to the "*" function
to search for strings.

If this is an occasional thing, just put the path in a "company data" table
and use a dlookup to get it. I'd probably put the file name in there also so
if they change that you can just smile.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top