I have a command button (cmdHyper) that takes the user to a specific file folder and asks them to select a photo of their asset. It then takes the name of the photo and sends it to the spreadsheet. I would like to be able to have it return a hyperlink instead of just the name of the file, but can't figure it out.
Here's what I have so far...
Private Sub cmdHyper_Click()
ChDrive "C"
ChDir "C:\Documents and Settings\m2odlsap\Desktop\Dev. Proj\Water Safety\WS_Asset_Photos"
Dim jpgName$, arr
jpgName = Application.GetOpenFilename(FileFilter:="All Files,*.jpg", Title:="Look for .jpg file")
arr = Split(jpgName, "\")
With Me.txtHyper
If arr(UBound(arr)) = "False" Then
.Text = ""
Else
.Text = "=HYPERLINK(Left(arr(UBound(arr)), Application.Find("", arr(UBound(arr))) - 1)"
End If
End With
End Sub
I'll admit to having found the basework for the code on the net and modifying it to fit my filenames. I keep getting an OBJECT error with the second .Text line. Any help would be appreciated greatly.
Here's what I have so far...
Private Sub cmdHyper_Click()
ChDrive "C"
ChDir "C:\Documents and Settings\m2odlsap\Desktop\Dev. Proj\Water Safety\WS_Asset_Photos"
Dim jpgName$, arr
jpgName = Application.GetOpenFilename(FileFilter:="All Files,*.jpg", Title:="Look for .jpg file")
arr = Split(jpgName, "\")
With Me.txtHyper
If arr(UBound(arr)) = "False" Then
.Text = ""
Else
.Text = "=HYPERLINK(Left(arr(UBound(arr)), Application.Find("", arr(UBound(arr))) - 1)"
End If
End With
End Sub
I'll admit to having found the basework for the code on the net and modifying it to fit my filenames. I keep getting an OBJECT error with the second .Text line. Any help would be appreciated greatly.