How to Fix Excel VBA SendKeys Not Working for Acrobat Save As PDF
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.

- 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.
Ensure that your VBA editor is open and you have backed up your existing macro code before making changes to the SendKeys commands.
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.
Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.
Find the line in your macro code that uses Application.SendKeys "{ENTER}" to confirm the Acrobat Save As dialog.
Change the command to Application.SendKeys "~". The tilde character functions as a carriage return in VBA.
Run the macro again to ensure the Acrobat Save As PDF dialog is successfully confirmed and the file saves without manual intervention.

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. Open your Spreadsheet: Launch WPS Spreadsheet and open the document you wish to convert.
- 2. Access the Export Feature: Click on the 'Menu' button in the top left corner and select 'Export to PDF'.
- 3. Configure PDF Settings: Choose your desired export range, layout, and save path in the dialog box.
- 4. Save the File: Click 'Export to PDF' to instantly save your document as a PDF without relying on external printer macros.

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.




