Others

Copy a PowerPoint Hyperlink to the Clipboard Using VBA

Ayan MasoodAyan Masood Nov 2, 2026 870 views

Question details

The user wants to copy a predefined hyperlink from a PowerPoint shape directly to the clipboard using a VBA macro, without relying on external software.

Copy a PowerPoint Hyperlink to the Clipboard Using VBA
Product
Microsoft PowerPoint
Device & OS
not provided
Scenario
Assigning a macro to a clickable shape in a presentation so that clicking it copies a stored URL to the clipboard.
Observed behavior
Previous VBA scripts tested by the user failed to work, and they need a reliable method to create a working button that copies the URL.
Before you start

Ensure the Developer tab is enabled in your PowerPoint ribbon and your file is saved as a Macro-Enabled Presentation (.pptm) to allow VBA scripts to run.

Solution 1Recommended

Use VBA to Copy the Hyperlink via a Temporary Text Box

Create a macro that extracts a URL stored in a shape, places it in a temporary text box, copies the text, and deletes the box.

Because PowerPoint VBA cannot interact with the Windows clipboard easily without complex API calls, a reliable workaround is to spawn a temporary text box on the slide. The macro populates it with the URL, copies the text using standard PowerPoint commands, and immediately removes the box.

You can store the target URL within the shape's alternative text or tags so the macro knows what to copy.

1
Open the VBA Editor

Press Alt + F11 to open the VBA Editor, insert a new Module, and define a new sub-routine named CopyTheHyperlink.

2
Write the VBA Code

Write code to retrieve the URL stored in the clicked shape's tags. Add error handling to check if a shape was actually clicked and if a valid URL exists.

3
Create and Copy from a Temporary Text Box

Add commands in your macro to create a temporary text box shape on the active slide, assign the retrieved URL to its text frame, execute the TextRange.Copy method, and then Delete the temporary shape.

4
Assign the Macro to a Shape

Return to your slide, select the target shape, navigate to Insert > Action, select 'Run macro', and choose CopyTheHyperlink.

Use VBA to Copy the Hyperlink via a Temporary Text Box
Macro Execution: Macros only trigger when the presentation is in Slide Show mode. Additionally, if you need this macro across multiple files, save it as a PowerPoint Add-in (.ppam).
Free Microsoft Office alternative

Create and Manage Presentations Easily with WPS Office

While configuring VBA macros in PowerPoint can be highly technical, WPS Office offers a seamless, user-friendly environment for creating rich, interactive presentations. It is fully compatible with Microsoft PowerPoint formats, making your transition smooth and effortless.

Highly compatible with Microsoft PowerPoint (.ppt, .pptx, .pptm) formatsLightweight and runs smoothly on older devicesFree to use with a familiar, intuitive user interfaceBuilt-in tools for hyperlinking and slide interactions without needing complex code
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my PowerPoint macro running when I click the shape?

Action buttons and 'Run Macro' click events assigned to shapes do not trigger while in the normal editing view. Ensure you are in Slide Show mode and that macros are enabled in your Trust Center settings.

Can I use this VBA script in other PowerPoint files?

By default, the macro is only available in the presentation where it was created. To use it across multiple files, you need to save the presentation containing the macro as a PowerPoint Add-in (.ppam).

Is there a way to copy text to the clipboard in VBA without a temporary text box?

Yes, but it requires using the DataObject from the Microsoft Forms 2.0 Object Library or calling Windows API functions, which can be more complex and prone to cross-platform compatibility issues compared to the temporary text box workaround.