Read hyperlink in excel sheet in VB.net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zino

    Read hyperlink in excel sheet in VB.net

    I have an excel sheet that have one of its cells as a hyperlink

    I need to read this cell through Vb.net and get the value of the hyperlink
    (the whole path ex: \\c:\document\. .... ..... ... .. , not only the cell
    content)

    how can I do that

    thanks for help
  • Kevin Yu [MSFT]

    #2
    RE: Read hyperlink in excel sheet in VB.net

    Hi Zino,

    First of all, I would like to confirm my understanding of your issue. From
    your description, I understand that you need to get the hyperlink in an
    Excel cell in VB.NET. If there is any misunderstandin g, please feel free to
    let me know.

    As far as I know, when we have filled data from an Excel worksheet to a
    .NET DataSet, all the values for this kind of field have been converted to
    string type. Then, we cannot figure out which part is the hyperlink. Do you
    have other contents in the same cell with the hyperlink which prevent you
    from figuring it out?

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."

    Comment

    • Kevin Yu [MSFT]

      #3
      RE: Read hyperlink in excel sheet in VB.net

      Hi Zino,

      First of all, I would like to confirm my understanding of your issue. From
      your description, I understand that you need to get the hyperlink in an
      Excel cell in VB.NET. If there is any misunderstandin g, please feel free to
      let me know.

      As far as I know, when we have filled data from an Excel worksheet to a
      .NET DataSet, all the values for this kind of field have been converted to
      string type. Then, we cannot figure out which part is the hyperlink. Do you
      have other contents in the same cell with the hyperlink which prevent you
      from figuring it out?

      Kevin Yu
      =======
      "This posting is provided "AS IS" with no warranties, and confers no
      rights."

      Comment

      • Peter Huang

        #4
        RE: Read hyperlink in excel sheet in VB.net

        Hi,

        I think we may try to read the Hyperlinks by using automation.
        The code below will print the cell(b5)'s hyperlink address and displayed
        text.

        Dim ex As New Excel.Applicati onClass
        ex.Workbooks.Op en("C:\temp\boo k1.xls")
        Dim sheet As Excel.Worksheet = ex.ActiveSheet
        Dim rg As Excel.Range = sheet.Cells(5, 2)
        Debug.WriteLine (rg.Hyperlinks( 1).Address)
        Debug.WriteLine (rg.Hyperlinks( 1).TextToDispla y)
        ex.Quit()


        You may have a try and let me know if that is what you want.

        Best regards,

        Peter Huang
        Microsoft Online Partner Support

        Get Secure! - www.microsoft.com/security
        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        Working...