VBA & Macro Problems

How to Open an EXE Relative to a PowerPoint Presentation Path Using VBA

John WilsonJohn Wilson Nov 2, 2026 869 views

Question details

The user needs to launch an external executable (.exe) file using a relative path based on the current location of the PowerPoint presentation file.

How to Open an EXE Relative to a PowerPoint Presentation Path Using VBA
Product
PowerPoint
Device & OS
not provided
Scenario
Automating the launch of an external application from within a presentation slide show without hardcoding the absolute directory path.
Observed behavior
A VBA macro needs to dynamically determine the presentation's directory, format the string by adding necessary backslashes, and trigger the EXE via an Action Setting on a shape.
Before you start

Ensure that your presentation is saved to your computer before testing, as an unsaved presentation will not have a valid ActivePresentation.Path.

Solution 1Recommended

Use a VBA Shell Command with ActivePresentation.Path

Create a VBA macro that dynamically retrieves the presentation's folder path and uses the Shell command to execute an application.

In VBA, the ActivePresentation.Path property returns the path of the current presentation, but it omits the trailing backslash. You must concatenate a backslash before appending the executable's name to create a valid path.

You can also navigate the directory structure. For example, to reference the parent folder containing the presentation folder, you can append "\..\" to the path.

1
Access the VBA Editor

Open your presentation and press Alt + F11 to open the VBA Editor. Insert a new module.

2
Write the Shell Command Macro

To open an executable in the same folder, write your macro to include: Shell ActivePresentation.Path & "\" & "Whatever.EXE". To open an executable in the parent folder, use: Shell ActivePresentation.Path & "\..\" & "Whatever.EXE".

3
Save as a Macro-Enabled Presentation

Go to File > Save As, and choose 'PowerPoint Macro-Enabled Presentation (*.pptm)' to ensure your VBA code is saved.

4
Assign the Macro to a Shape

Insert a shape onto a slide. Right-click the shape, click 'Action Settings' (or select 'Action' from the Insert tab), select 'Run Macro', and choose the macro you just created from the dropdown menu. The executable will launch when you click the shape during the slide show.

Use a VBA Shell Command with ActivePresentation.Path
Application.Path is Read-Only: You cannot assign a new path directly to the Application.Path property because it is read-only. Always use a concatenated string inside the Shell command.
Advanced Presentation Features

Create and Run VBA Macros Easily with WPS Office

WPS Presentation provides robust support for VBA macros, allowing you to automate tasks and run external programs using standard VBA commands. Enjoy seamless macro execution and file management in a highly compatible environment.

  1. 1. Open the Developer Tools: Launch WPS Presentation, navigate to the 'Tools' tab, and locate the Developer tools section.
  2. 2. Access the VBA Editor: Click 'VBA Editor' to open the scripting environment and input your Shell command script using ActivePresentation.Path.
  3. 3. Set Up an Action Button: Insert a shape or button on your slide, go to the 'Insert' tab, click 'Action', and assign your newly created macro to trigger on mouse click.
  4. 4. Save as PPTM: Save your document in the PPTM format to keep macros intact and ensure they run correctly during your presentation.
Fully supports standard Microsoft PowerPoint VBA syntax like ActivePresentation.Path.Highly compatible with PPTX and PPTM (Macro-enabled) file formats.Lightweight, fast, and features a user-friendly interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my relative path macro return a 'File not found' error?

This usually happens because ActivePresentation.Path does not include a trailing backslash. If you forget to add "\" between the path and the executable name, the system will look for a malformed path (e.g., C:\FolderWhatever.EXE instead of C:\Folder\Whatever.EXE).

Can I run an executable located in a subfolder relative to the presentation?

Yes. You can append the subfolder name to the path by modifying the concatenation string. For example: Shell ActivePresentation.Path & "\SubfolderName\" & "Whatever.EXE".

Does this method work if the presentation is stored on a network drive?

Yes, ActivePresentation.Path will return the UNC network path (e.g., \\Server\Folder) if the presentation is opened from a network drive. The VBA Shell command can handle valid UNC paths properly.