2

I have a connection string in an Excel Spreadsheet that links to other spreadsheets. All works well. However, the file and directory are written as absolute. Can this be relative?

There are two files in the same directory N:\Files\ProjectName\Clients\Alpha\Project.xlsm and N:\Files\ProjectName\Clients\Alpha\Data1.xlsm and on in another directory N:\Files\ProjectName\Clients\Beta\Data2.xlsm

The connection strings are:

DSN=Excel Files;DBQ=N:\Files\ProjectName\Clients\Alpha\Data1.xlsm;DefaultDir=N:\Files\ProjectName\Clients\Alpha

and

DSN=Excel Files;DBQ=N:\Files\ProjectName\Clients\Beta\Data2.xlsm;DefaultDir=N:\Files\ProjectName\Clients\Beta

I want it to work without the n:\ reference?

eg similar to:

DSN=Excel Files;DBQ=..\Data1.xlsm;DefaultDir=..\Alpha (Because it's in the same directory) and

DSN=Excel Files;DBQ=...\Beta\Data2.xlsm;DefaultDir=...\Beta (because it is in the next directory)

Any advice welcomed.

Cheers, Graeme

Dee_wab
  • 1,171
  • 1
  • 10
  • 23
  • Have you seen this post? https://stackoverflow.com/questions/213584/relative-instead-of-absolute-paths-in-excel-vba/213602 – G.Thinh Feb 18 '20 at 22:57

0 Answers0