How to Open a URL from a Word VBA Button and Export to PDF
Question details
The user wants to trigger a web URL from a command button using Word VBA and ensure the link remains functional when saved as a PDF or opened on a Mac.

- Product
- Microsoft Word
- Device & OS
- Windows, Mac
- Scenario
- Creating interactive documents with clickable buttons that direct to web URLs and exporting them to PDF.
- Observed behavior
- VBA command buttons execute code successfully in Word for Windows but fail to function when exported to PDF or opened in Word for Mac.
Determine if your document will primarily be used within a Windows Word environment or if it needs to be shared as a PDF. Standard hyperlinks are universally supported across PDFs and macOS, whereas VBA macros are heavily restricted outside of the Windows desktop application.
Insert Standard Hyperlinks for Cross-Platform & PDF Support
Use standard Word hyperlink fields instead of VBA buttons if your document will be exported to PDF or used on Mac.
VBA (Visual Basic for Applications) macros, including command buttons, do not execute in PDF files or Word for Mac due to security and platform restrictions. Using standard hyperlinks ensures your web links remain fully clickable regardless of the format or device.
Highlight the text, shape, or image you want to act as your clickable link.
Right-click the selection and choose 'Hyperlink', or press the Ctrl+K keyboard shortcut.
Type or paste the target web URL in the 'Address' field and click 'OK'.
Save the document as a PDF using 'Save As' and selecting the PDF format. The standard links will remain active in the resulting file.

Use VBA ShellExecute for Windows Word Environments
If you strictly require a VBA command button in a Windows-only Word document, use the ShellExecute API function to open the default web browser.
Use WPS Writer to Create Clickable PDFs Easily
WPS Writer provides an intuitive way to add standard hyperlinks to text and shapes, allowing you to export interactive PDFs effortlessly. It fully supports Microsoft Word formats and offers strong compatibility for daily document processing without relying on complex VBA code.
- 1. Open your Document: Launch WPS Writer and open the document you wish to edit.
- 2. Add a Link: Highlight the text or select a shape, go to the 'Insert' tab, click 'Hyperlink', and enter your URL.
- 3. Export to PDF: Click the 'Menu' button in the top left corner, select 'Export to PDF', and save your interactive document.

Frequently Asked Questions
Why doesn't my VBA command button work in a PDF?
PDFs are static document formats that do not support embedded Word VBA (Visual Basic for Applications) macros or ActiveX controls. Any scripts or interactive actions attached to VBA command buttons are disabled or stripped during the conversion process.
Can I use VBA macros in Word for Mac?
Word for Mac has very limited support for VBA and does not support ActiveX controls like Windows command buttons. Because of this, command buttons created in Windows will typically not function on Mac, making standard hyperlinks the best alternative for cross-platform sharing.
How do I make a shape act like a clickable button in PDF?
Instead of using a developer ActiveX control, insert a standard shape (like a rounded rectangle) from the 'Insert' tab. Right-click the shape, select 'Hyperlink', and enter your web URL. When you export this document to PDF, the shape will act as a clickable button.




