adding hyperlink with relative path to Excel

  • Thread starter Thread starter Peter Holschbach
  • Start date Start date
P

Peter Holschbach

Hi,

I have a Excel document where I want to add a hyper link to other Excel
documents with a relativ path name.

Example:
.\Test Excel\2.4 Funktion\11_Test.xls

I add this link

....
string relPath = ".\Test Excel\2.4 Funktion\11_Test.xls";
Microsoft.Office.Interop.Excel.Range range = ResultSheet.get_Range("A" +
Row.ToString(), Missing.Value);
range.Hyperlinks.Add(range, relPath, Missing.Value, Missing.Value, relPath);
....

In Excel I can see the text ".\Test Excel\2.4 Funktion\11_Test.xls" in the
cell, it is blue marked as a hyperlink but it didn't work as hyperlink. If I
start editing this hyperlink in Excel, I only see a empty URL.

Next step was replace all spaces by %20 and all "\" by "/"

.....
string relPath = ".\Test Excel\2.4 Funktion\11_Test.xls";
string relLink = relPath.Replace('\\', '/').Replace(" ","%20");

Microsoft.Office.Interop.Excel.Range range = ResultSheet.get_Range("A" +
Row.ToString(), Missing.Value);
range.Hyperlinks.Add(range, relLink , Missing.Value, Missing.Value,
relPath);
.....

no difference, the cell is shown with blue text, but the link is not
working.
Any idea ?

thanx
Peter
 
have you tried holding shift and then clicking the cell? or holding ctrl and
clicking the cell ?

sometimes you need to do that to make the link work.

that's really all the advice I've got for ya. Ihope you find your answer and
report it back here for others.
 
Back
Top