Macro that creates a PDF and save it on a specific folder

Accessme2

Registered User.
Local time
Today, 15:18
Joined
May 12, 2004
Messages
64
Hi everyone,
I have this problem I been searching a way to do the following:
have a button that will run a macro, that It will print the active set print area on a hard copy then save a copy as a PDF on a set directory. So the user will have only click on a button and will get a hard copy and a pdf copy on a specific file.
My problem is that all the code that i have found will work only if the PDF Distiller is set as a default so the Pdf copy is create just fine but not a hard copy. so if I change the default printer to the printer then can't get the PDF.

Does anyone have any idea how can I get both...
this is one of the code that I have:

Dim PSFileName As String
Dim PDFFileName As String
PSFileName = "G:\Temp\Purvis-quotes\" & ActiveSheet.Range("A13").Value & ".ps"
PDFFileName = "G:\Temp\Purvis-quotes\" & ActiveSheet.Range("A13").Value & ".pdf"

'Print the Excel range to the postscript file
ActiveWindow.SelectedSheets.PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe distiller on Ne11", _
printtofile:=True, Collate:=True, prtofilename:=PSFileName

'Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Samsung ML-2510 Series on USB002:", Collate:=True
 
Have you tried creating two private subs that are called by the public sub (the macro run by the button press). By seperating into two seperate processes, the print then the save, you may get around the issue you are having.

Apologies if this doesn't help, but I don't have a specific answer, but this is how I have resolved issues like this before.
 

Users who are viewing this thread

Back
Top Bottom