adding hyperlink with relative path to Excel

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
 
R

roger_27

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top