?
Solved

Run an application from vb

Posted on 2003-03-06
4
Medium Priority
?
147 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
  • 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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month9 days, 20 hours left to enroll

569 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