Shell Function


Shell ( app [, style] )

Runs an executable program.

The shell function has two parameters. The first one, app is the name of the program to be executed. The name of the program in app must include a  .PIF, .COM, .BAT, or .EXE file extension or an error will occur.  The second argument, style is the number corresponding to the style of the window .  It is also optional and if omitted the program is opened minimized with focus.

Window styles:

 

Example:

    ' This example uses Shell to leave the current application and run

    ' the Calculator program included with Microsoft Windows; it then

    ' uses the SendKeys statement to send keystrokes to add some numbers.

 

    Sub Main()

        Dim I, X, Msg   ' Declare variables.

        X = Shell("Calc.exe", 1)   ' Shell Calculator.

        For I = 1 To 5   ' Set up counting loop.

            SendKeys I & "{+}", True   ' Send keystrokes to Calculator.

        Next I ' to add each value of I.

        AppActivate "Calculator"   ' Return focus to Calculator.

        SendKeys "%{F4}", True   ' Alt+F4 to close Calculator.

    End Sub