VBA & Macro Problems

How to Use an Excel VBA Macro to Start an EXE Application

Nimra MalikNimra Malik Nov 2, 2026 870 views

Question details

The user wants to run a VBA macro in Excel to launch an external executable application, such as Notepad.

How to Start an EXE Application Using an Excel VBA Macro
Product
Excel
Device & OS
not provided
Scenario
Automating workflows by opening an external program directly from an Excel workbook without leaving the spreadsheet environment.
Observed behavior
The goal is to successfully execute an external application via a VBA script using the built-in Shell function.
Before you start

Ensure that you have enabled the Developer tab in your spreadsheet software and that your macro security settings are configured to allow VBA scripts to run.

Solution 1Recommended

Use the VBA Shell Function to Launch an Application

The most straightforward way to run an executable file from a macro is by utilizing the built-in VBA Shell function.

The Shell function initiates an executable program and returns a double-precision integer representing the program's task ID if successful. It also allows you to specify the window style, such as launching the application maximized, minimized, or hidden in the background.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

Click on 'Insert' in the top menu, then select 'Module' to create a blank script window.

3
Enter the Shell Macro Code

Type the following code into the module window: Sub StartApp() Shell "notepad.exe", vbMaximizedFocus End Sub

4
Customize the File Path

If the application is not in the system path, replace 'notepad.exe' with the full file path of the specific application you want to open (for example, "C:\\Program Files\\App\\app.exe").

5
Run the Macro

Press F5 or click the Run button on the top toolbar to execute the macro and launch the specified application.

Use the VBA Shell Function to Launch an Application
Application Paths: If the executable is not mapped in your Windows environment path variables, you must provide the complete directory path for the Shell function to locate and run it.
Advanced Macro Support

Run VBA Macros Seamlessly in WPS Spreadsheet

WPS Office Spreadsheet fully supports VBA macros, allowing you to automate tasks and execute Shell functions just like you would in Microsoft Excel. It offers a highly compatible and familiar environment for all your data processing needs.

  1. 1. Download WPS Office: Install WPS Office and open your .xlsm or .xlsb macro-enabled workbook in WPS Spreadsheet.
  2. 2. Enable Developer Tools: Navigate to the Developer tab to access the VBA Editor and adjust your macro security settings.
  3. 3. Run Your Shell Macro: Execute your macro code to flawlessly launch external applications directly from your WPS spreadsheet.
Fully compatible with Microsoft Excel VBA scripts and modulesSupports advanced Shell functions and external application triggersLightweight, fast, and free to downloadFamiliar user interface for seamless migration
microsoft office alternative - wps office

Frequently Asked Questions

Can I use a VBA macro to open a specific file in the launched application?

Yes. Within the Shell function, you can append the file path after the application executable name, for example: Shell "notepad.exe C:\\path\\to\\your\\file.txt", vbNormalFocus.

Why do I get a 'File not found' error when running the macro?

This usually happens when the application's executable is not included in your system's PATH. To fix this, provide the full file path to the executable, such as Shell "C:\\Windows\\System32\\notepad.exe".

How do I make the application open in the background without taking screen focus?

You can change the window style argument in the Shell function from vbMaximizedFocus to vbHide, vbMinimizedNoFocus, or vbNormalNoFocus to run the application invisibly or minimized without interrupting your current workflow.