Solved

Loading programs from another program

Posted on 1998-08-24
11
137 Views
Last Modified: 2010-04-30
I need the code for a command button on a program...to load another program I have made.
0
Comment
Question by:Klueny2
  • 5
  • 3
  • 3
11 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1430837
You have to use the shell function

Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", vbMaximizedFocus)      

vbHide      0      Window is hidden and focus is passed to the hidden window.
vbNormalFocus      1      Window has focus and is restored to its original size and position.
vbMinimizedFocus      2      Window is displayed as an icon with focus.
vbMaximizedFocus      3      Window is maximized with focus.
vbNormalNoFocus      4      Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus      6      Window is displayed as an icon. The currently active window remains active.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430838
Hi,

    Option Explicit
    Dim ret3&
    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 cmdRunCalculator_Click()

    ' Run any program EXE,COM from here.

      ret3& = ShellExecute(Me.hwnd, "Open", "calc.exe", "", App.Path, 1)

     End Sub


      Private Sub Form_Load()
      End Sub


0
 

Author Comment

by:Klueny2
ID: 1430839
Also, lets say I wanted to send this program to somebody else in a zip file...and after they unzip it,...will the command button still work to open the prog? if not, how can I do this if I can?
0
 
LVL 14

Expert Comment

by:waty
ID: 1430840
I don't anderstand your question
0
 

Author Comment

by:Klueny2
ID: 1430841
Ok, sorry..I need to know the code so that a command button opens up another form in the same program.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 14

Expert Comment

by:waty
ID: 1430842
Sub cmdButton_Click()

   frm2.Show

End Sub
0
 

Author Comment

by:Klueny2
ID: 1430843
It gives me a run-time error, and says object required
0
 

Author Comment

by:Klueny2
ID: 1430844
It gives me a run-time error, and says object required
0
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 50 total points
ID: 1430845
the answer to your Question: "I need the code for a command button on a program...to load another program I have made."

Let say your program name is MyProgram.exe

THIS IS A WORKING CODE.
use this code as is first , then change the line,
ret3& = ShellExecute(Me.hwnd, "Open", "calc.exe", "", App.Path, 1)

with this line,
ret3& = ShellExecute(Me.hwnd, "Open", "MyProgram.EXE", "", App.Path, 1)

where MyProgram.EXE is your program that you wish to run..
(Note: Path is the path you choose: c:\MyProgram.EXE , E:\prog\MyProgram.EXE and so on.

If you have any question email to shay@hili.com or post here.


========== start code =========
'in your general declaration:
Option Explicit
           Dim ret3&
           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()

           ' Run any program EXE,COM from here.
            ' Replace the calc.exe with your program "MyProgram.EXE"
             ret3& = ShellExecute(Me.hwnd, "Open", "calc.exe", "", App.Path, 1)

     End Sub

=========== end code ========
Shay.

0
 

Author Comment

by:Klueny2
ID: 1430846
I'm sorry...where do I put this following code? I'm kinda new and have no idea where it goes..

Option Explicit
    Dim ret3&
    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
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430847
The code
Option Explicit
 Dim ret3&
 Private Declare Function........
Go in (general) (Declarations)

If need more help or to fix your code email to shayplace@hotmail.com
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now