Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer depends on what you actually want to print; for Excel (old versions) I usually print to postscript printer driver; then use <a href="http://www.ghostscript.com/" rel="nofollow">GhostScript</a> command line to convert from PS to PDF.</p> <p>You need to have the GhostScript files. Here is the code: </p> <pre><code>Option Explicit Dim PSPrinterSetupName As String Dim svPsFileName As String Dim svPDFName As String Sub testRun() 'set up a printer using driver "HP C LaserJet 4500-PS" or something similar 'name it "PostScript Writer" 'set it to "print to file" 'set the name of the printer to use PSPrinterSetupName = "PostScript Writer" 'set the postscript file name (must be 8.3 notation; 'no long names; no spaces; you can move and rename the file later) svPsFileName = "C:\Temp\input1.ps" 'set the PDF name (must be 8.3 notation; 'no long names; no spaces; you can move and rename the file later) svPDFName = "C:\Temp\Output1.PDF" Call printToPS Call ConvertToPDF End Sub Sub printToPS() Dim PrinterInUse As String PrinterInUse = Application.ActivePrinter Worksheets("Sheet1").PrintOut ActivePrinter:=PSPrinterSetupName, PrintToFile:=True, PrToFileName:=svPsFileName Application.ActivePrinter = PrinterInUse End Sub Sub ConvertToPDF() Dim fso Dim lcCmd As String Set fso = CreateObject("Scripting.FileSystemObject") lcCmd = "C:\Progra~1\GS\Misc\GhostS~1\GSWIN32C.EXE " &amp; _ "-q -dNOPAUSE -IC:\Progra~1\GS\Misc\GhostS~1\lib;./fonts " &amp; _ "-sFONTPATH=./fonts -sFONTMAP=C:\Progra~1\GS\Misc\GhostS~1\lib\FONTMAP.GS " &amp; _ "-sDEVICE=pdfwrite -sOUTPUTFILE=" &amp; svPDFName &amp; " -dBATCH " &amp; svPsFileName Shell (lcCmd) End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload