ShellExecute Subroutine

Finds the file name of the program that is associated with a specified file and either runs the program for the file or prints the file. FactoryGlobals provides the Declare statement in GlobalSubroutines so you can use this Windows API call without declaring it in your procedures.

Syntax

ShellExecute (hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd)

Properties

The ShellExecute subroutine syntax has these parts:

Part

Description

hwnd

Long. A handle to a window.

lpOperation

String. The string “Open” to open the lpFile document or “Print” to print it. You can use vbNullString to default to “Open”.

lpFile

String. A program name or the name of a file to print or open using the associated program.

lpParameters

String. A string with parameters to pass to the exe file if lpszFile is an executable file. VbNullString if lpszFile refers to a document file or if on parameters are used.

lpDirectory

String. The full path of the default directory to use.

nShowCmd

Long. A constant value specifying how to show the launched program.

Return Value

Long. The success of the ShellExecute call. A value greater than 32 signifies success.

Remarks

ShellExecute is a Windows API call.

 

Example