Click here to Skip to main content
14,640,651 members
Rate this:
Please Sign up or sign in to vote.
See more:
I would like to insert hyperlink to file into excel cell.

What I have tried:

I was trying use this code but once hyperlink is inserted to excel when I checking the hyperlink is in cell but not active until I edit the cell then press enter.
I think its happens because the hyperlink is inserted as a text.
Could anyone can help me ?

<pre>Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=EXCEL_DATA\2SV REARS RFT.xls;Extended Properties = ""Excel 12.0 Xml;HDR=YES"""
        'Create an INSERT INTO SQL statement
        Dim insertStatement As String = "INSERT INTO [" & NOWEEK.Text & "$] ([LINE], [Date], [Shift], [Frame Type], [Quantity], [Problem], [Weld Number], [Welder]) VALUES ('=HYPERLINK(C:\SMART" & FRAMETYPE.Text & ".xlsx)','" + datee.Text + "','" + CHOSESHIFT.Text + "','" + FRAMETYPE.Text + "'," + QUANTITY.Text + ",'" + PROBLEM.Text + "','" + WELDNUMBER.Text + "','" + WELDERNAME.Text + "')"
        'Create a connection object to connect to the Excel Workbook
        Dim connection As New OleDbConnection(connectionString)
        'Create a command object that will execute the insert statement
        Dim command As New OleDbCommand(insertStatement, connection)
        'Open the connection, execute the statement and close the connection
        'Dispose of the connection and command objects
        'Call the RefreshData routine so that you can see that data was indeed added.
Updated 4-Feb-18 5:13am
Rate this:
Please Sign up or sign in to vote.

Solution 1

In a short: to be able to add hyperlink, you have to use: Hyperlinks.Add Method (Excel)[^].
Rate this:
Please Sign up or sign in to vote.

Solution 2

I check that but this is to create macro in excel.
What I looking is to add hyperlink to excel cell using application created in vb .net.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100