Do you need to use sendkeys to specify the file name? In the Adobe PDF
printer preferences box, if you set the prompt for file name option to an
existing folder, then all the .PDFs generated are dumped there. The files
are by default saved with the primary name and .PDF suffix. You can then
programmatically pick the file from that folder, rename/move it.


Regards

Ajit


-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of chris12345
Sent: Monday, June 15, 2009 6:11 PM
To: MS EXCEL AND VBA MACROS
Subject: $$Excel-Macros$$ Print to pdf using sendkeys


Hi,

I wonder if someone can help me. I am trying to print a Excel document
to Acrobat using the Adobe PDF printer driver. I can get the initial
print dialog box up fine (where you can select the driver, etc.), and
can send an "{ENTER}" to progress to the next dialog where you must
input the required pdf filename. This is where the problem is - I
cannot get this dialog to accept any sendkeys so nothing happens. As
soon as I click cancel/save on this box, the keys are then sent to
Excel.

My code is as follows:

SendKeys "^p~", True 'bring up the initial printer dialog box.
Application.Wait Now + TimeSerial(0, 0, 1)
SendKeys "{TAB}", True
Application.Wait Now + TimeSerial(0, 0, 1)
SendKeys "{TAB}", True 'tab down to the OK button
Application.Wait Now + TimeSerial(0, 0, 1)
SendKeys "~", True 'press enter to progress to the next box
SendKeys "C:\PDFFILE.PDF", True 'enter the filename
Application.Wait Now + TimeSerial(0, 0, 1)
SendKeys "%s", True ' alt s to save the file

Any suggestions at all, in particular about how I might manage to give
focus to the second "save file" dialog would be much appreciated.

Thank you




--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain  @ [email protected] or
Ashish Jain @ [email protected]
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---

Reply via email to