Selecting a hyperlink file

D

Dave

I want to be able to use a file select type dialog to attach a
hyperlink to a field

and have been using the code below. The problem is, that while it
selects the file corectly, when I click on the field it does not act as
a hyperlink.


My code is

Declare Function GetFileInfo Lib "msaccess.exe" Alias "#56" (FSI As
FileSelInfo, ByVal fOpen As Integer) As Long

Function fOpenFile(Optional strFile As Variant = Null, Optional
strFilter As String = "All Files (*.*)", Optional strDir As String =
"", Optional strTitle As String = "", Optional strButton As String =
"")

'Use to choose a file to open
Dim FSI As FileSelInfo

With FSI
.lngFlags = 0
.strFilter = RTrim(strFilter) & vbNullChar
.lngIndex = CInt("0")
If Not IsNull(strFile) Then
.strFile = RTrim(strFile) & vbNullChar
End If
.strTitle = RTrim(strTitle) & vbNullChar
.strButton = RTrim(strButton) & vbNullChar
.strDir = RTrim(strDir) & vbNullChar
End With

If GetFileInfo(FSI, True) = 0 Then fOpenFile =
fTrimNull(FSI.strFile)
End Function
 
G

Guest

To act as a hyperlink you either need to set the table field or form control
up as a hyperlink or setup the control so it has an event that uses the
application.followhyperlink method to open the document.


If you are wanting to open the file as part of your code just add the
following to the end of your code

Application.Followhyperlink "FilePathand Name"

Daniel
 
D

Dave

Thanks for that - that works nicely and the file (say a word doc) is
opened - but it doent have the focus - it is relegated (as it were) to
the task bar - any ideas?
 

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