?
Solved

Run an application from vb

Posted on 2003-03-06
4
Medium Priority
?
146 Views
Last Modified: 2010-04-07
How do you run a specific application from Vb?  i would like to click on a button and open a file in its native application as if I had double clicked it in explorer.
0
Comment
Question by:dan657
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:raskle
ID: 8083182
You can use the shell function to run any executable program.  After that, you can use the Sendkeys function to send keystrokes to that application.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctShell.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vastmSendKeys.asp
0
 

Expert Comment

by:raskle
ID: 8083185
Correction: Sendkeys is actually a statement.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 100 total points
ID: 8083540
Shellexecute will open any file with it's default app:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Call ShellExecute(hwnd, "Open", ("C:\Somefile.doc"), "", App.Path, 1)
End Sub
0
 

Expert Comment

by:diya123
ID: 8087587
hai,
just use the command


Shell "path", vbNormalFocus

happiness always
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

752 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