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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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
Back
Top