Problem with hyperlink RRS feed

  • Question

  • User2127927318 posted

    Hi All,

    Below is the code for adding hyperlink in Excelsheet but its giving me error.

    Dim xlWorkBook As Excel.Workbook
    Dim xlWorkSheet As Excel.Worksheet

    xlWorkBook = New Excel.Application().Workbooks.Open("C:\Blubaker\Practice.xls")
    xlWorkSheet = xlWorkBook.ActiveSheet

    xlWorkSheet.Cells(1, 1) = xlWorkSheet.Hyperlinks.Add(Anchor:="Selection", Address:="http://www.MySite.com", TextToDisplay:="Clickhere")


    Is this the correct way to add hyperlink in Excel if not Can you please tell me how can i do that.

    below part of the above code i have generated using 'macro' in excel.

    Anchor:="Selection", Address:="http://www.MySite.com", TextToDisplay:="Clickhere"





    Friday, January 8, 2010 1:30 PM

All replies

  • User2127927318 posted

    Can anyone please shed some light on it.

    How to add hyperlink in Excelsheet using vb.net.

    Or it is not possible ?



    Monday, January 11, 2010 6:17 AM
  • User-1659704165 posted


    if u have Predefined File.

    Then <a href="<name and path of file>" id ="static Id"/>

    for if want to Acess the link dynmically u may runat="server"

    <a href="<name and path of file>" id ="static Id" runat="server"/>

    staticid.Add.Attribute("Add","<New file name>");

    Monday, January 11, 2010 6:20 AM
  • User2127927318 posted

    Hi Avinash,

    Thanks for your reply.

    Yes, I have prdefined file.

    Can u tell me where i have to write this code

    "staticid.Add.Attribute("Add","<New file name>");"

    What is the "staticid" and where i will write the below code:

    <a href="<name and path of file>" id ="static Id"/>




    Monday, January 11, 2010 7:15 AM
  • User-1659704165 posted

    When U put runat server tag the <a href will become severside Acessable..

    Id.Add.Attribute("href",""<your excel file path>"");


    U may use Hyperlink control

    Monday, January 11, 2010 7:34 AM