Solved

Loading programs from another program

Posted on 1998-08-24
11
139 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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
 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

809 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