Solved

Loading programs from another program

Posted on 1998-08-24
11
143 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

707 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