Best way to open a file in its native app with VB code?

Posted on 2001-08-24
Last Modified: 2012-08-13
I am creating a file and I would like for it to open into its native application right after I create it.  What is the best way to accomplish this task?
Question by:joesmow

Expert Comment

ID: 6422868
If the native application is associated to open files with the extension of the file you create you can simply call Shell(sFilename, vbNormalFocus) if you want it to appear to the user or with vbMinimizedFocus if you don't want it to appear to the user.  It depends a lot on the type of native application that opens the file.  If it's not associated with the file extension you may need to figure out where the application is and then put the application path and name followed by a space and your filename.

LVL 27

Expert Comment

ID: 6422871
What is going to be your native application?

Author Comment

ID: 6422962
The native app will be AutoCAD.
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

LVL 16

Accepted Solution

Richie_Simonetti earned 50 total points
ID: 6422964
You were not clear enoght so i will post some possible ways:
'find executable for a given file

' open a file with default associated exe

If you plan to open that file with your program, you need to do an entry in registry and add and extension, so when file is doble-clicked, it will be open with your app.
Your program must read Command$ variable to get avobe mentioned.
Hope it helps

LVL 16

Expert Comment

ID: 6422980
' create file association with VB.

Author Comment

ID: 6423084
The native app will be AutoCAD.

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question