How to open any third party application using the shell function in Excel VBA. We can open applications like Acrobat Reader, Google browser, OpenOffice, CamtasiaStudio, etc. automatically using the Shell function. ‘It runs an executable program and returns a Variant (Double) representing the program’s task ID if successful; otherwise, it returns zero.’
Syntax of Shell Function: Shell(pathname, [ windowstyle ])
|Pathname||This named argument is required; the data type is Variant (String). We specify the path to the ‘exe’ file of the application or program|
|windowstyle||This name argument is optional. The data type is a Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized.|
The windowstyle named argument can have these values:
|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 in the taskbar 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.|
If the Shell function executes the named file successfully, it returns the task ID of the started program. The task ID is a unique number that identifies the running program. If the Shell function can’t start the named program, an error occurs.
On the Macintosh, vbNormalFocus, vbMinimizedFocus, and vbMaximizedFocus all place the application in the foreground; vbHide, vbNoFocus, and vbMinimizeFocus all place the application in the background.
Reference: Shell function