Link to home
Start Free TrialLog in
Avatar of StevenPMoffat
StevenPMoffat

asked on

Use relative pathname in Excel Query to Access database

Is there a way to make the reference to the database name a relative path rather than a fullpathname starting at the C: directory,. In this sample I want to have Source=V3.0 PMW 160 Master Plan.mdb instead of starting with the C: directory.  If I put that in, it gets converted to a full pathname

Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\PMW 160 Plans\V3.0 PMW 160 Master Plan.mdb;Mode=Share Deny Write;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False
Avatar of Member_2_933725
Member_2_933725

To my knowledge, no. I'm saying this based on experience with various other connection strings for different database files, where the name of the database always requires the full path and filename.

May I ask why you would want this?

Regards
Mike
Avatar of rockiroads
might be possible, you could try this

'Change directory to where path of xls file is
chdir("C:\PMW 160 Plans")

'Open xlsfile using relative path

Avatar of StevenPMoffat

ASKER

For Mike:   I have a spreadsheet that is linked to an Access database file.  I want to pass them around to a number of individuals together and not have them have to change the pathname in the query.  

For Rock.  I setup the link in Excel to Access by using the Connection box of the Edit OLE DB Query box so I don't know if your recommended commands would work?
What about using ODBC then. Each user will have to create an ODBC entry on their PC. This will point to the database.
Then see if you can connect via ODBC instead
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This sounds like it should work in my case.  Thanks for sticking with it.