简体   繁体   中英

Create a link to a Word document from an Excel cell using a relative path

In an Excel cell, I want to link to a MS Word file, eg 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM