How to Open an EXE Relative to a PowerPoint Presentation Path Using VBA
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.

- 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.
Ensure that your presentation is saved to your computer before testing, as an unsaved presentation will not have a valid ActivePresentation.Path.
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.
Open your presentation and press Alt + F11 to open the VBA Editor. Insert a new module.
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".
Go to File > Save As, and choose 'PowerPoint Macro-Enabled Presentation (*.pptm)' to ensure your VBA code is saved.
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.

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. Open the Developer Tools: Launch WPS Presentation, navigate to the 'Tools' tab, and locate the Developer tools section.
- 2. Access the VBA Editor: Click 'VBA Editor' to open the scripting environment and input your Shell command script using ActivePresentation.Path.
- 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. Save as PPTM: Save your document in the PPTM format to keep macros intact and ensure they run correctly during your presentation.

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.




