How to inset a hyperlink not by a physical address


hi, i made a xls file in a test folder and i want Adding a link to a file inside this folder such as worksheet.Hyperlinks.Add(4 + col, i + 1, 1, 1,"c:\test\test.doc")

but it is a physical address, if i move this folder to another driver such as d:,the link can not work.

Is it posiable to add address like MS excel use relative address? i use code worksheet.Hyperlinks.Add(4 + col, i + 1, 1, 1,"test.doc") can not work :(


I will fix this issue. You can try to add the link as:

workbook.Worksheets[0].Hyperlinks.Add(1, 1, 1, 1,"..\\test.doc");


i tried your code, it seems not work,i open xls that i created,on link shows file:///e:\test\test1.xls-…\test.doc ,error object


I think you are using VB code, please change the code to :

workbook.Worksheets(0).Hyperlinks.Add(1, 1, 1, 1,"..\test.doc")