Open document, how to

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Hi,

I have a field storing the file path of a document (can be word, excel
etc...). I put a bottun on the form for open the file but I don't know what
command to use.

Any advice?

SF
 
It opens the file and also return error "Runtime error 438"

Private Sub cmdOpenDoc_Click()
Dim StrSQL As String
StrSQL = "'" & Me.DocLink & "'"
Print fHandleFile(Me.DocLink, WIN_NORMAL)
End Sub

SF
 
You can't use Print in conjunction with the function for ShellExecute.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)
 
Thank you for youe advice, but by removing the Print, I got compile error,
Expected:=

If IsNull(Me.DocLink) Then
FormattedMsgBox "Blank entry@No location of file specified@***********",
vbOKOnly + vbInformation
Exit Sub
Else
strSQL = "'" & Me.DocLink & "'"
fHandleFile(Me.DocLink, WIN_NORMAL) <============ compile error,
Expected:=
End If

SF
 
fHandleFile is a function. Functions return values, so Access expects you to
assign the value of the function to a variable. Since an explicit data type
isn't given in the function declaration, that means the function returns a
Variant, so you'd need something like:

Dim varReturn As Variant

varReturn = fHandleFile(Me.DocLink, WIN_NORMAL)

If you don't care about the value that's returned by the function, you have
two other options. You can use the "Call" keyword:

Call fHandleFile(Me.DocLink, WIN_NORMAL)

or you can leave out the parentheses around the parameters:

fHandleFile Me.DocLink, WIN_NORMAL
 
Back
Top