Open to Veiw(Read only) files from VB

M

MechEngr

I am using the following code to open (to view only) files as part of a File
management DB. The code open all files with extensions that have programs
registered (txt, pdf, xls, doc, etc) but for some files (like txt, exe, etc)
the file or program will open twice. Is there a better way to open (to view)
files?

Set fs = Application.FileSearch
With fs
.LookIn = Path
.FileName = FileName

If .Execute(SortBy:=msoSortbyFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then

Set ctl = Me!cmdFollowLink01
With ctl
.Visible = True
.HyperlinkAddress = Address
.Hyperlink.Follow
End With

Else

MsgBox "File Does Not Exist or Link is Broken"

End If

End With



Help is appreciated in advance.
 

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