tags:

views:

63

answers:

1

Hi

I have some code that creates a xml excel spreadsheet. This sheet contains hyperlinks to documents in subdirectories. An example of the href for the link would be ".\dir1\dir2\document.pdf". When the spreadsheet is opened in ms excel 2007 this link is wrongly rendered as "file:///c:\temp\dir1\dir2\dir1\dir2\document.pdf".

I have found this article https://openxmldeveloper.org/forums/post/709.aspx but unfortunalty this is not working for me. Any thoughs?

A: 

As far as I can tell, this behavior is actually a facet of Excel's save process. While Excel will respect and properly execute relative links in a document, as soon as you save all links in the document will be re-rendered to a hardcoded path. So if you Save As, your link will be pointing to the old path. And then of course every save thereafter will be to that same file. How to fix it? well short of using notepad after the fact or disallowing save beforehand, I don't think you really can with embedded links.

As a workaround though you could just use the hyperlink formula. As a formula it should not get overwritten.

=HYPERLINK(".\deleteme.xls","Test")

Oorang