File paths relative to database file

T

Todd

I'm using Access 2007 on Vista. I am about to start sharing my database
with others in my company so I'm trying to get it polished up a bit. My
database is split into two parts (application and data). I have created an
installation file that stores the application side of the database in the
Application Data folder of the user. Since that exact path will vary from
one user to another, how can I get the path to certain files. For example,
I may want to use VBA to call up
c:\users\Todd\AppData\Roaming\MyDatabase\WordFile.docx. If someone else
installs my database, their file will be located somewhere else. Is there a
way to reference files relative to the location of the application file of
the database? Thanks!!! I hope I explained myself well enough!
 
D

Dirk Goldgar

Todd said:
I'm using Access 2007 on Vista. I am about to start sharing my database
with others in my company so I'm trying to get it polished up a bit. My
database is split into two parts (application and data). I have created
an installation file that stores the application side of the database in
the Application Data folder of the user. Since that exact path will vary
from one user to another, how can I get the path to certain files. For
example, I may want to use VBA to call up
c:\users\Todd\AppData\Roaming\MyDatabase\WordFile.docx. If someone else
installs my database, their file will be located somewhere else. Is there
a way to reference files relative to the location of the application file
of the database? Thanks!!! I hope I explained myself well enough!


CurrentProject.Path gives you the path to the folder where the front-end
resides.
 
T

Todd

One more little related problem...

I have code that calls up an acrobat file...
Call Shell(strAcrobatPath & strFDF, vbNormalFocus)

strAcrobatPath is the path to acrobat.exe. strFDF is the path to an FDF in
the AppData folder. The code won't work however because the user folder is
longer than 8 characters. For example, the strFDF for me is c:\users\Todd
Sadowski\appdata\roaming\CFP Database\fdf\temp.fdf" Of course, the easy
workaround would be to change "Todd Sadowski" to "toddsa~1", but this path
is being generated using CurrentProject.Path. Is there a fix for what I'm
trying to accomplish? Thanks again!
 
A

Albert D. Kallal

It seems to the worse problem is that you have to find, know, and maintain
the path named to acrobat.exec on every different machine and every time
they upgraded it'll be a different path name!

I would suggest you try the following :

application.FollowHyperlink strPDF

if you correctly surround your string with quotes, then spaces will not
matter at all.

eg:

strPDF = chr$(34) & "c:\users\Todd
Sadowski\appdata\roaming\CFP Database\fdf\temp.fdf"

& "chr$(34)

application.FollowHyperlink strPDF

Of course the above has some wrapping due to the newsgroup reader, but if
you put quotes around the string, you'll not have to convert and worry
about spaces (or 8 char file names). Furthermore if you dump the use of the
shell command, then you'll be able to launch the PDF application regardless
of what version of Adobe they have installed...or even If they are using
something other than Adobe to read PDF files.
 
T

Todd

Great! You solved my problem and helped me out with the other frustration I
was having to deal with! Thank you!
 

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