Is it possible to to take textbox value (Ex. Text) convert it to a hyperlink and export to an Excel spreadsheet?
I have a project written in Visual Studio.net that takes the textbox values and exports it to Excel everything works great. But now I have a request to add a picture file of equipment in our plant to my spreadsheet. I created my opendialog and a button and textbox and I can select the file and send to Excel with no problem I just can't figure out how to export it as a Hyperlink. Below is my code. Please help!!
What I have tried:
Public Class Form4
Dim row_min As Object
Dim row_max As Object
Dim col_min As Object
Dim col_max As Object
Dim value1 As Integer
Dim value2 As Integer
Dim strtext As String
Private Sub Form11_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim xlApp = GetObject("", "Excel.Application")
Dim xlBook = xlApp.Workbooks.Open("C:\Users\lockhartB\Desktop\Mobile Equipment.xls")
Dim xlSheet = xlBook.Worksheets("Sheet1")
'set visibility
xlApp.Visible = False
' Display the range's rows and columns.
row_min = xlSheet.UsedRange.Row
row_max = row_min + xlSheet.UsedRange.Rows.Count - 1
col_min = xlSheet.UsedRange.Column
col_max = col_min + xlSheet.UsedRange.Columns.Count - 1
'enter data
xlSheet.cells(row_max + 1, col_min).Value = ComboBox1.Text
xlSheet.cells(row_max + 1, col_min + 1).Value = ComboBox3.Text
xlSheet.cells(row_max + 1, col_min + 2).Value = TextBox3.Text
xlSheet.cells(row_max + 1, col_min + 3).Value = TextBox4.Text
xlSheet.cells(row_max + 1, col_min + 4).Value = TextBox1.Text
xlSheet.cells(row_max + 1, col_min + 5).Value = TextBox2.Text
xlSheet.cells(row_max + 1, col_min + 6).Value = ComboBox2.Text
xlSheet.cells(row_max + 1, col_min + 7).Value = TextBox5.Text
xlSheet.cells(row_max + 1, col_min + 8).Value = TextBox6.Text
xlSheet.cells(row_max + 1, col_min + 9).Value = ComboBox4.Text
xlSheet.cells(row_max + 1, col_min + 10).Value = TextBox7.Text
xlSheet.cells(row_max + 1, col_min + 11).Value = TextBox8.Text
xlSheet.cells(row_max + 1, col_min + 12).Value = TextBox9.Text
'save changes
xlBook.Save()
'close workbo
xlBook.Close(False)
'quit app
xlApp.Quit()
ComboBox1.SelectedIndex = -1
ComboBox2.SelectedIndex = -1
ComboBox3.SelectedIndex = -1
ComboBox4.SelectedIndex = -1
For Each control As Control In Me.Controls
If TypeOf (control) Is System.Windows.Forms.TextBox Then
control.Text = ""
End If
Next
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
OpenFileDialog1.ShowDialog()
TextBox9.Text = OpenFileDialog1.FileName
Try
Shell(TextBox9.Text)
Catch ex As Exception
End Try
End Sub
End Class