How can I write code to open file ?

N

Nova

In my form. I choose button wizard then select run application, If I select
file by .exe such as msword.exe, acrobat.exe it can open that application
file, but if select such as aaa.doc or bbb.pdf it cannot open file. How can I
open it?

in event procedure I see call shell(file name and path)

if file name is .exe.it can open
if not .exe then can not open
 
S

scubadiver

Insert the following into the "on click" event (or where ever). "[File]" is
the field and "Qry_filetype" is the table or query.

Dim varURL As Variant

varURL = DLookup("[File]", "Qry_FileType")

If IsNull(varURL) Then
MsgBox "Sorry, this document does not exist!", vbOKOnly + vbInformation
Else
Application.FollowHyperlink varURL
End If

End Sub
 

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