Open Any Third Party Application Using Shell Function

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 ])

PathnameThis named argument is required; the data type is Variant (String). We specify the path to the ‘exe’ file of the application or program
windowstyleThis 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.
Named Arguments of Shell Function

The windowstyle named argument can have these values:

ConstantValueDetails
vbHide0Window is hidden and focus is passed to the hidden window.
vbNormalFocus1Window has focus and is restored to its original size and position.
vbMinimizedFocus2Window is displayed as an icon in the taskbar with focus.
vbMaximizedFocus3Window is maximized with focus.
vbNormalNoFocus4Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus6Window is displayed as an icon. The currently active window remains active.
Windowstyle Named Argument

Open Any Third Party Application Using Shell Function in VBA

Remarks
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

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.