Siebel VB Language Reference > VB Language Reference >

Shell Function

This standard VB function starts a Windows application and returns its task ID.


Shell(pathname, [windowStyle])



A string or string expression evaluating to the name of the program to execute


An integer indicating how the program's window is to be displayed:

  • 1 if a normal window with focus
  • 2 if a minimized window with focus
  • 3 if a maximized window with focus
  • 4 if a normal window without focus
  • 7 if a minimized window without focus

The task ID for the program, a unique number that identifies the running program.


Shell runs an executable program. Pathname can be the name of any valid BAT, COM, EXE, or PIF file. Arguments and command line switches can be included. If pathname is not a valid executable file name, or if Shell cannot start the program, an error message occurs.

If windowStyle is not specified, the default of windowStyle is 1 (normal window with focus).


This example opens Microsoft Excel upon the click of a button. For other examples, read Right Function and SendKeys Statement.

Sub Button1_Click
   Dim i as long
   i = Shell("C:\Program Files\Microsoft
End Sub

See Also

SendKeys Statement

Siebel VB Language Reference