tjdickinson
Board Regular
- Joined
- Jun 26, 2021
- Messages
- 61
- Office Version
- 365
- Platform
- Windows
I've resorted to using SendKeys for the time being to create a PDF from my workbook using Acrobat (so the file has bookmarks). I've mapped out the key sequence:
Three things happen:
The main issue is getting the Create PDF window to respond to the first "enter" key, and I imagine the issue will be the same when the save dialog opens. Any help is greatly appreciated. Thanks!
VBA Code:
Sub exportPDF()
Workbooks(ActiveWorkbook.Name).Activate
SendKeys "%y2", True
SendKeys "c", True
SendKeys "w", True
Application.Wait (Now() + TimeValue("00:00:10"))
SendKeys "{ENTER}", True
Application.Wait (Now() + TimeValue("00:00:03"))
SendKeys "{ENTER}", True
End Sub
- There is a long delay before opening the Create PDF window (which is done in the first two SendKeys actions); could the Application.Wait be interfering?
- Nothing more happens when the Create PDF pop up opens. When I ran it with debug.print, all the keystrokes were recorded. So it's sending them, but they're not being registered by the pop up window.
- NumLock always gets deactivated. No clue why.
The main issue is getting the Create PDF window to respond to the first "enter" key, and I imagine the issue will be the same when the save dialog opens. Any help is greatly appreciated. Thanks!