View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Andy Andy is offline
external usenet poster
 
Posts: 2
Default Automated Printing

My colleagues at work regularly have a several hundred of Excel
spreadsheets that need Printing on either white paper or as PDFs. I
have created a user form, so that each team member can choose which
print method they want before printing. I have produced some VBA that
will then do the job automatically.

The code mostly works fine for printing paper copies. However each
person in the network has there printer set up differently. On one
machine the printer will be listed as "Brother HL-2460 series on Ne01:"
on another it will be "Brother HL-2460 series on Ne03:" etc. Could
someone tell me how to set things up, so that the setting is the same
for all people in my team. E.G. I would like it if the setting is
"Brother HL-2460 series on Ne01:" for everyone.
When printing PDFs I have the same problem. The active printer is
listed as "Adobe PDF on Ne03:", on another it may be "Adobe PDF on
Ne04:" etc.
A more serious problem is that the PDFs only print on the computer
where an early version of PDF writer is installed. I have found out
that a way round this problem is to get the macro to first write a
postscript file using the acrobat distiller, then convert the
postscript to a PDF. I found following code on the web:

Sub PrintPDF()

' 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

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

The above code looks like it will do fine. However when I go to file =
print in an excel document I do not get the option to set the printer
to "Acrobat Distiller". If I can't do the job manually, I can't get
the job done with a macro. Could someone help me set up the my system
so I can use the distiller in this way?

Thanks,

Andy.