Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code by JabbaTheNut’s Thread 223-414162 i can not run

Status
Not open for further replies.

Stubby1933

Technical User
Apr 12, 2012
1
I have been unable to get the code by JabbaTheNut’s Thread 223-414162 to run. I am using Windows , Excel 2003,Didtiller 9.5. yes I know it has been a while. I picked it up in 05
I have checked and unchecked the “Rely on system Founts only, Do not use document fonts.” I have also removed the extra “t” from “prttoFilename printer line”
I have included my code. Which I can step through to the “Active Printer”. line

Tek-Tips Forums AREA: Programmers/Graphics and Publishing
FORUM: Adobe: Acrobat Forum
SUBJECT: Excel to PDF Using Visual Basic

HANDLE: JabbaTheNut
POSTED ON: Nov 27
QUESTION:
I have used the following VB code to print an Excel range to an Adobe Acrobat .PDF file. The steps to accomplish this are as follows:

1. Print the range to a postscript file using Acrobat Distiller
2. Convert postscript file to .PDF using Acrobat Distiller API.

Make sure that you uncheck the "Do not send fonts to Distiller" option in the Distiller properties. You do this by entering the Distiller properties>>General Tab>>Printing Preferences>>Adobe PDF Settings and uncheck the "Do not send fonts to Distiller" option. You will get an error if you don't do this.

In the Excel Visual Basic Editor, make sure you include a reference to Acrobat Distiller.

Here is the code....
*********************************************
Private Sub CommandButton1_Click()

' Define the postscript and .pdf file names.
Dim PSFileName as String
Dim PDFFileName as String
PSFileName = "c:\myPostScript.ps"
PDFFileName = "c:\myPDF.pdf"
' Print the Excel range to the postscript file
Dim MySheet As WorkSheet
Set MySheet = ActiveSheet
MySheet.Range("myRange").PrintOut copies:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True, prttofilename:=PSFileName
' Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

End Sub

And that is all there is to it! I hope this tip is helpful to some of you.
Game Over, Man!
**************************************************************
My Code:

Sub PrintCalcs()
'Code for print macro
'uncheck the Rely on system fonts etc..........



' Define the postscript and .pdf file names.
Dim PSFileName As String
Dim PDFFileName As String
PSFileName = "c:\temp\myPostScript.ps"
PDFFileName = "C:\Libraries\Documents\Amydocs110407\B Master Program\PrintTest"
' Print the Excel range to the postscript file
Dim MySheet As Worksheet
Set MySheet = ActiveSheet
MySheet.Range("Summary").PrintOut copies:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True, prtofilename:=PSFileName

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


Thanks, Stubby1933
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top