it works then it doesn't then it does

monnoir

New Member
Joined
Jun 22, 2006
Messages
9
This little macro will PDF-print and save with filename= Cell A8 value. A value that change before the next print. Usually every thing work fine but once in a while, for a reason I would like to know, the sytem call for a filename input instead of reading it from cell A8. Then, without any change, the macro work fine again. Any hint?
Thanks!


Sub printPDF()
Dim strOldPrinter As String
'save default printer string
strOldPrinter = Application.ActivePrinter
Application.SendKeys "{return}" & Range("a8") & "{return}", True
Application.Dialogs(xlDialogPrint).Show
'restore old printer string
End sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
Hi,

I tried using Sendkeys to give pdf files a name a while ago and ran into a similar problem, gave up eventually as was advised it probably wasn't ever going to work consistently.

If you have Adobe Acrobat have a look at this:

http://www.mrexcel.com/board2/viewtopic.php?t=200960&highlight=pdf

It took me ages to get it to get it to work as coding's something I'm learning very slowly.

Otherwise I've seen various other threads on printing to pdf files using other freely available software if you search the boards.

Hope this helps.
 

Forum statistics

Threads
1,136,349
Messages
5,675,243
Members
419,556
Latest member
rdecker12

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top