Copy a PowerPoint Hyperlink to the Clipboard Using VBA
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.

- 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.
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.
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.
Press Alt + F11 to open the VBA Editor, insert a new Module, and define a new sub-routine named CopyTheHyperlink.
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.
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.
Return to your slide, select the target shape, navigate to Insert > Action, select 'Run macro', and choose CopyTheHyperlink.

Manually Copy the Hyperlink (Alternative Method)
If you do not strictly require a macro, you can manually copy the hyperlink from the shape during the editing process.
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.

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.




