0

Is it possible to have a generic user reference in the data connection string of an Excel data connection?

I have a external reference to another workbook that I would like to share with my colleagues, and in the collaboration software that we use there is a path for each user's synced folder, such as:

C:\Users\"Username"\....

Is there a prompt similar to %USERPROFILE% that I could use in this instance? Here is a full connection string example:

DSN=Excel Files;DBQ=C:\Users\"Username"\...\File.xlsx;DefaultDir=C:\Users\"Username"\...;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;

1 Answer 1

1

To generate C:\Users\Username use: environ("HOMEDRIVE") & environ("HOMEPATH")

see Environ Function and also Windows APIs & Wscript at Daily Dose of Excel - Get the Path to My Documents in VBA

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the answer @EEM! Unfortunately, I am not using VBA to create the data connection parameters within the worksheet (and I am simply using the Data Connection wizard to define the path). I think I have a temporary solution, but I might need to resort to VBA in the end!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.