INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Opening external files from access - opening with default program

Opening external files from access - opening with default program

Opening external files from access - opening with default program

(OP)
Hello I have a form which has a textbox called txtFilePath

txtFilePath contains the Path, including extension of a file name.

I would like to have a button which opens the file.

I have tried the hyperlink method, and whilst this works OK, it often throws up security warnings.

Could someone recommend some vba which will launch these files without the security warnings - preferable using the default program for the file extension.

Many thanks Mark

RE: Opening external files from access - opening with default program

Take a look at this:

CODE

Option Explicit

Private Sub Command1_Click()
Call OpenDocument("C:\Temp\SomeFile.txt")
End Sub

Public Sub OpenDocument(ByRef strDocPath As String)
Dim G As Long
G = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & strDocPath, vbNormalFocus)
End Sub 

You can place this Public Sub OpenDocument somewhere in your code (a standard Module?), pass a valid path + file name with extension, and it is open with the default application.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Opening external files from access - opening with default program

(OP)

Andrzejek, you are a genius - thank you for all your help.

Regards Mark

RE: Opening external files from access - opening with default program

Moss100,
If Andy's a genius he must deserve a star.

Duane
Hook'D on Access
MS Access MVP

RE: Opening external files from access - opening with default program

(OP)
Indeed. I thought I'd already done that - how do I tell?

RE: Opening external files from access - opening with default program

You can tell by looking at the thread.

Duane
Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close