PDA

View Full Version : userform textbox save file path in cell as hyperlink



remco77a
01-31-2020, 06:49 AM
Hi there,

Hopefully someone can help me, since recently I am working on VBA and have been looking for a solution for saving a hyperlink for a week.
I will explain what I am doing, I have created a user form where a file from the server is stored in a text box using a file path.
When I save the userform then all data is sent correctly to my data base. but unfortunately the file path is not recognized as a hyperlink but as text value.
My question is actually how can i save my file path as a hyperlink in my excel file in one way?

I use this code to browse to my file:

Private Sub CmdFoto_Click()

'BROWSE FOR FILE

Dim FileName As String

FileName = Application.GetOpenFilename()
txtFoto.Value = FileName
txtFoto.SetFocus

End Sub

For save the hyperlink to my excel file in column "k" I use this:


.Range("K" & iRow).Value = frmNew.txtFoto.Value

Artik
01-31-2020, 08:08 AM
.Hyperlinks.Add Anchor:=.Range("K" & iRow), _
Address:=frmNew.txtFoto.Value, _
TextToDisplay:=frmNew.txtFoto.Value '(Or Blah, blah, blah ;))

Artik

remco77a
01-31-2020, 08:45 AM
.Hyperlinks.Add Anchor:=.Range("K" & iRow), _
Address:=frmNew.txtFoto.Value, _
TextToDisplay:=frmNew.txtFoto.Value '(Or Blah, blah, blah ;))

Artik


Thanks a lot, it works!

remco77a
01-31-2020, 12:19 PM
Thanks a lot, it works!
I'm do some testings, and didn't Change the code but I get a error 5 code, of this code, after I try to save the value.
What could that be?