File path: Not a long one, but in the same folder...

zapppsr

Board Regular
Joined
Aug 19, 2010
Messages
189
I have a spreadsheet linked to a databse which is a txt file and it is at the following adress:

W:\LIDERAN\Demandas_Direcao\PCP\Alocacao\TXT\aloca.txt

I'm looking for a way to refer to de file "aloca.txt" without having to be in that address, but at the same path the spreadsheet is.

For instance, if the spreadsheet is at:

:: C:\Budget

and it is moved to...

:: H:\2012\Balance

with the txt file at the same folder, when I update data, it would look at the new folder root, instead of looking at the whole path it was before.

In short, I need to refer to the txt file and ignore the path, and make Excel look at the same folder the spreadsheet is.

Like using some wild card in the link:

Instead of:

W:\LIDERAN\Demandas_Direcao\PCP\Alocacao\TXT\aloca.txt

something like %aloca.txt

Can you guys help me?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try like this:
Code:
Dim strTFPath As String
strTFPath = ThisWorkbook.Path & Application.PathSeparator & "aloca.txt"
 
Upvote 0
Try:

Code:
ThisWorkbook.Path & "\aloca.txt"

or

Code:
ActiveWorkbook.Path & "\aloca.txt"
 
Upvote 0
Where do I put this code?

I don't code in Excel.

I was expecting something simple, like editing this dialog box:

Clipboard01.jpg
 
Upvote 0
I think, this dialog is in Portuguese language and I don't know if I have used its English equivalent. I will PM one forum expert who will be in a position to understand it better.
 
Upvote 0
Looking at the image in #4 it seems this is not an Excel issue (as far as i know)

It's related with Windows. How to set a path to a network drive using environment variables (path) or something like that?

M.
 
Upvote 0
I do not know a way to achieve this, I am sorry. Probably a Windows system / network admin would be the right person to handle such task. I'd recommend you post this on Windows related forum.
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,844
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top