HyperLink Documents

J

Jo

Hi

I have been asked to develop a database that has the
capasity to hyperlink to existing documents on the network.

Does anybody know how I could get the windows navigation
form up (like when you do save as and you can go through
your computer) so that I could just navigate to the path
of the document and select it, then in my database the
path would show where the document is located (with the
file name) then anyone who wants to view the document
could just click on the link and open it up.

I hope this is clear - I know what I want it to do...its
just getting it to do it.

Thanks for any help you can give me on this.
J
 
A

Alastair MacFarlane

J,

You could you a variation on the following code.

Private Sub FilePath_Click()
On Error GoTo err_handler
DoCmd.Hourglass True
Call LoadWordFile(Me.FilePath)
exitSub:
DoCmd.Hourglass False
Exit Sub
err_handler:
DoCmd.Hourglass False
Resume exitSub
End Sub

Private Sub LoadWordFile(strWordDoc As String)
On Error GoTo err_handler:
Dim wrdApp As Word.Application
If FileExist(strWordDoc) = False Then Err.Raise 5273
Set wrdApp = New Word.Application
With wrdApp
.Documents.Open strWordDoc
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set wrdApp = Nothing
DoCmd.RunCommand acCmdAppMinimize
exitSub:
DoCmd.Hourglass False
Exit Sub
err_handler:
Select Case Err.Number
Case 5273
MsgBox "The requested file is no longer at the
current location. " & vbCrLf & _
"This could be because the file has
been deleted, moved " & vbCrLf & _
"or renamed. Access will not open this
document!" & vbCrLf & vbCrLf & _
"A new instance of Word will be opened
for you " & vbCrLf & _
"to find the file yourself!",
vbCritical, "Missing File Warning - #Error - 5273"
Set wrdApp = New Word.Application
With wrdApp
.Documents.Add "Normal"
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set wrdApp = Nothing
DoCmd.RunCommand acCmdAppMinimize
Case 4198
wrdApp.Quit SaveChanges:=wdDoNotSaveChanges
MsgBox "There has been a problem accessing
this file." & vbCrLf & _
"Could it already be open?" & vbCrLf &
vbCrLf & _
"If it is not open then contact the
database" & vbCrLf & _
"admininstrator quoting Response
Code: bs4198pke", vbCritical, "Response code: 4198"
Case Else
MsgBox Err.Description, vbOKOnly, "System
Information"
End Select
Resume exitSub:
End Sub

Private Function FileExist(Filename As String) As Boolean
If Dir$(Filename) = "" Then
FileExist = False
Else
FileExist = True
End If
End Function

I hope this helps!

Alastair MacFarlane
 

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