How to Preserve Excel Worksheet Links When Creating PDFs with VBA
Question details
The user wants to export Excel workbooks to PDF using VBA while keeping internal worksheet links and navigation functional.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Automating the creation of PDF documents from Excel workbooks using VBA scripts, where interactive elements like links are required in the output.
- Observed behavior
- Internal hyperlinks connecting different worksheets are often lost, broken, or converted to plain text in the resulting PDF file.
Ensure that the internal hyperlinks in your Excel workbook are fully functional before running any VBA export scripts, as broken source links cannot be magically preserved in the final PDF.
Use the ExportAsFixedFormat Method in VBA
Using Excel's native ExportAsFixedFormat method with the correct parameters is the most reliable way to preserve both internal and external links during PDF conversion.
Many users rely on virtual PDF printers (like Microsoft Print to PDF) in their VBA scripts using the PrintOut method. However, printing inherently strips interactive elements. To retain links, you must use the native ExportAsFixedFormat method.
Press Alt + F11 in Excel to open the Visual Basic for Applications editor, and locate the module containing your export script.
Replace any PrintOut commands with the ExportAsFixedFormat method applied to your target Workbook or Worksheet object.
Ensure your code includes 'Type:=xlTypePDF'. A basic implementation looks like: ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\path\to\file.pdf".
Execute the macro to generate the PDF. Open the output file in a standard PDF viewer to verify that clicking the worksheet links navigates correctly.

Repair Links Post-Export with a PDF Editor
If Excel version limitations prevent links from exporting correctly, you can recreate or repair the PDF link annotations after the export process.
Export Spreadsheets to PDF with Links Intact using WPS Office
WPS Office provides highly capable built-in tools to export your spreadsheets directly to PDF while perfectly preserving all internal and external hyperlinks, bypassing complex VBA troubleshooting.
- 1. Open your Spreadsheet: Launch WPS Office and open the spreadsheet containing your hyperlinks.
- 2. Access the Export Tool: Click on 'Menu' in the top-left corner and select 'Export to PDF'.
- 3. Configure and Export: In the export dialog box, configure your save location and ensure the standard export options are selected. Click 'Export'.
- 4. Test the Links: WPS Office will automatically open the resulting file in its integrated PDF viewer so you can immediately test the working links.

Frequently Asked Questions
Why do my Excel hyperlinks turn into plain text in the exported PDF?
This usually happens if your VBA script uses a virtual printer (like Microsoft Print to PDF) rather than a native exporter. Print drivers flatten the document for physical paper, stripping out interactive elements like hyperlinks.
Does ExportAsFixedFormat preserve external links as well as internal ones?
Yes, when used correctly, the ExportAsFixedFormat method in VBA preserves both internal worksheet navigation links and external web URLs.
Do I need Adobe Acrobat installed to keep VBA exported links working?
No. Using the native Excel ExportAsFixedFormat method or WPS Office's built-in PDF converter will retain the links natively without requiring Adobe Acrobat.
What if my VBA script uses the PrintOut method?
The PrintOut method sends the document to a printer driver, which typically drops hyperlinks. You must modify your VBA code to use ExportAsFixedFormat to retain interactivity.




