Hyperlink problem

G

Guest

I made a text box that contains the address of a file on a shared drive. I
also made a button thats supposed to open up the file. when i press the
button, i get an error saying that it can't follow the hyperllink "File
name". it highlights the .follow part of the form.

Sub CreateHyperlink(ctlSelected As Control, _
strSubAddress As String, Optional strAddress As String)
Dim hlk As Hyperlink
Select Case ctlSelected.ControlType
Case acLabel, acImage, acCommandButton
Set hlk = ctlSelected.Hyperlink
With hlk
If Not IsMissing(strAddress) Then
.Address = strAddress
Else
.Address = ""
End If
.SubAddress = strSubAddress
.Follow
.Address = ""
.SubAddress = ""
End With
Case Else
MsgBox "The control '" & ctlSelected.Name _
& "' does not support hyperlinks."
End Select
End Sub
 
J

John Nurick

If you have a filespec (e.g "M:\Folder\Sub folder\File name.doc") in a
textbox txtFileSpec, all you need is

Application.FollowHyperlink Me.txtFileSpec.Value

There's no need to muck round with the Hyperlink property of other
controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top