VBA & Macro Problems

How to Fix Excel VBA SendKeys Not Working for Acrobat Save As PDF

Huda QurayshiHuda Qurayshi Nov 2, 2026 870 views

Question details

The user needs to fix an Excel VBA automation script where the SendKeys command fails to confirm the Save As PDF dialog in Acrobat.

How to Fix Excel VBA SendKeys Not Working for Acrobat Save As PDF
Product
Microsoft Excel, Adobe Acrobat
Device & OS
not provided
Scenario
Automating the process of saving an Excel workbook as a PDF using Adobe Acrobat via VBA macros.
Observed behavior
The Application.SendKeys "{ENTER}" command, which worked in Acrobat XI, fails to activate the confirmation control in the Acrobat Standard 2017 Save As dialog.
Before you start

Ensure that your VBA editor is open and you have backed up your existing macro code before making changes to the SendKeys commands.

Solution 1Recommended

Replace {ENTER} with Tilde (~) in VBA SendKeys

Modify the VBA script to use the tilde character instead of the Enter string, which successfully triggers the confirmation button in the newer Acrobat dialog.

Dialog-based automation using SendKeys is often sensitive to timing, window focus, and software version changes. Acrobat Standard 2017 handles dialog controls slightly differently than Acrobat XI, causing the explicit "{ENTER}" string to fail.

1
Open the VBA Editor

Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.

2
Locate the SendKeys Command

Find the line in your macro code that uses Application.SendKeys "{ENTER}" to confirm the Acrobat Save As dialog.

3
Update the Command

Change the command to Application.SendKeys "~". The tilde character functions as a carriage return in VBA.

4
Test the Macro

Run the macro again to ensure the Acrobat Save As PDF dialog is successfully confirmed and the file saves without manual intervention.

Replace {ENTER} with Tilde (~) in VBA SendKeys
Automation Restored: Using the tilde (~) acts as a direct carriage return in VBA, bypassing the parsing issues Acrobat 2017 has with the literal {ENTER} command.
Effortless PDF Export

Save Spreadsheets to PDF Natively with WPS Office

Avoid unreliable SendKeys automation and third-party PDF tools. WPS Office features a built-in, seamless PDF converter for spreadsheets, which can be easily automated using the WPS Macro Editor (VBA compatible) or executed manually in just two clicks.

  1. 1. Open your Spreadsheet: Launch WPS Spreadsheet and open the document you wish to convert.
  2. 2. Access the Export Feature: Click on the 'Menu' button in the top left corner and select 'Export to PDF'.
  3. 3. Configure PDF Settings: Choose your desired export range, layout, and save path in the dialog box.
  4. 4. Save the File: Click 'Export to PDF' to instantly save your document as a PDF without relying on external printer macros.
Built-in PDF converter without needing Adobe AcrobatHighly compatible with Microsoft Excel files and VBA macrosReliable automated workflows without SendKeys workaroundsFree and lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does SendKeys fail randomly in VBA macros?

SendKeys simulates manual keyboard input, which relies entirely on the target window having active focus. If another application pops up, the system lags, or the target window loads too slowly, the keystrokes are sent to the wrong place, causing the macro to fail.

Is there a better alternative to SendKeys for saving Excel to PDF?

Yes. Instead of automating Adobe Acrobat via SendKeys, you can use Excel's native ExportAsFixedFormat method in VBA. This directly saves a workbook or sheet as a PDF in the background without requiring any user interface interaction.

What other special characters can I use with SendKeys in VBA?

VBA SendKeys uses specific codes for modifier keys. For example, + is Shift, ^ is Ctrl, % is Alt, and ~ is Enter. Enclosing standard key names in braces like {TAB}, {ESC}, or {DOWN} also works for UI navigation.

How do I add a delay before executing a SendKeys command?

You can use Application.Wait Now + TimeValue("00:00:02") to pause the macro for a few seconds. This gives the target application dialog enough time to load and gain active focus before the keystrokes are transmitted.