Reputation: 301
In an Excel cell, I want to link to a MS Word file, e.g. to C:\MyFile\someDoc.docx
, using a relative path.
My Excel file is in the folder C:\MyFile
. So my path should be something like currentdirectory\someDoc.docx
so that I can mail the whole C:\MyFile
folder or transfer it somewhere else.
How can I do that?
I am aware how to link with an absolute path like C:\MyFile\someDoc.docx
but what if I transfer the Excel file to somebody. In the destination folder, will it still search for the C:\MyFile
location?
Upvotes: 3
Views: 1159
Reputation: 3875
You can get the location of your workbook using the CELL
function.
Enter the below formula in your sheet, say in cell B1
,
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1)
This will give you the root folder in which your workbook is present. Now in the cell in which you have the link to the docx
file, use the below formula,
=HYPERLINK(B1&"someDoc.docx","Click here")
Hope this helps. Even if you move the folder, this will work.
Upvotes: 3