+ Reply to Thread
Results 1 to 7 of 7

Printing as PDF

  1. #1
    cvach@mycaf.com
    Guest

    Printing as PDF

    I have a portion of a sheet that I want to print/save as a pdf to a
    folder on my hard drive. The folders location is C:\Documents and
    Settings\Compaq_Owner\Desktop\Invoices. I also want the file name to
    be the value found in cell j19 on the "PO Form" worksheet. Any help?


  2. #2
    Arvi Laanemets
    Guest

    Re: Printing as PDF

    Hi

    Download and install Cute PDF-Writer (http://www.cutepdf.com/)
    It installs as a printer. Now, you can write any documents (Excel, Word,
    various pictures, web pages, etc. to PDF format. Simply open the document,
    select Print from menu, select CutePDF Printer, and when you click on Print
    button, a file save dialog opens.


    Arvi Laanemets


    <cvach@mycaf.com> wrote in message
    news:1140463544.183203.297500@g43g2000cwa.googlegroups.com...
    > I have a portion of a sheet that I want to print/save as a pdf to a
    > folder on my hard drive. The folders location is C:\Documents and
    > Settings\Compaq_Owner\Desktop\Invoices. I also want the file name to
    > be the value found in cell j19 on the "PO Form" worksheet. Any help?
    >




  3. #3
    cvach@mycaf.com
    Guest

    Re: Printing as PDF

    Thank you for the response. However, I already know and have the
    capability of saving the worksheet as a PDF, but what I want to do is
    record it in a macro so that it will automatically Print/Save and
    insert the value in j19 as the filename. I do not want to have to
    enter in the information manually every time.


  4. #4
    Pete_UK
    Guest

    Re: Printing as PDF

    I had a similar requirement some time ago. What I ended up doing was to
    save the sheet as an xls file (for which you can build up the filename
    as necessary in a macro) and then change the printer to the PDF printer
    and print the xls file to this driver (then reset the printer
    afterwards). It was not fully automatic, however, as I still had to
    confirm manually which folder to save the file in.

    Hope this helps.

    Pete


  5. #5
    Dave Peterson
    Guest

    Re: Printing as PDF

    Maybe you could incorporate some of Jim Rech's code:

    http://groups.google.co.uk/group/mic...ee5b61dff842df

    or
    http://snipurl.com/mrp0


    cvach@mycaf.com wrote:
    >
    > I have a portion of a sheet that I want to print/save as a pdf to a
    > folder on my hard drive. The folders location is C:\Documents and
    > Settings\Compaq_Owner\Desktop\Invoices. I also want the file name to
    > be the value found in cell j19 on the "PO Form" worksheet. Any help?


    --

    Dave Peterson

  6. #6
    Pete_UK
    Guest

    Re: Printing as PDF

    Thanks for this link, Dave - I'll study it and see if it is still valid
    for what I was doing last November.

    Pete


  7. #7
    Michael Bednarek
    Guest

    Re: Printing as PDF

    On 20 Feb 2006 12:38:29 -0800, wrote in microsoft.public.excel:

    >Thank you for the response. However, I already know and have the
    >capability of saving the worksheet as a PDF, but what I want to do is
    >record it in a macro so that it will automatically Print/Save and
    >insert the value in j19 as the filename. I do not want to have to
    >enter in the information manually every time.


    These things can not be recorded in macros, you have to cut the
    code manually.

    Adobe Acrobat offers a COM interface to the VBA programmer; it's pretty
    expensive. Alternatively, the latest version of PDFCreator now also
    provides a COM interface and the distribution file includes examples.

    Here is a skeleton (taken from actual working code, but not tested
    in this incarnation):

    Option Explicit
    Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

    Sub PrtPDFCreator(theObject As Object)
    ' Print to the PDFCreator printer
    ' Needs a reference to PDFCreator.exe

    Const theFileRoot As String = "C:\Temp\PDFs\" ' Testing (must exist)
    Dim outName As String
    Dim strOldPrinter As String

    ' Add a reference to PDFCreator
    Dim myPDFCreator As PDFCreator.clsPDFCreator

    outName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & "-" _
    & Application.ActiveSheet.Name & "-" _
    & Format((Now), "HHNN-SS") & Format((Timer() * 100) Mod 100, "00") & ".PDF"

    Set myPDFCreator = New PDFCreator.clsPDFCreator
    With myPDFCreator
    If .cStart("/NoProcessingAtStartup") = False Then
    MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
    Exit Sub
    End If
    .cOption("UseAutosave") = 1
    .cOption("UseAutosaveDirectory") = 1
    .cOption("AutosaveDirectory") = theFileRoot
    .cOption("AutosaveFilename") = outName
    .cOption("AutosaveFormat") = 0 ' 0 = PDF
    .cClearCache
    End With

    ' Perform the print action
    strOldPrinter = ActivePrinter
    theObject.PrintOut ActivePrinter:="PDFCreator"

    ' Wait until the print job has entered the queue
    Do Until myPDFCreator.cCountOfPrintjobs = 1
    DoEvents
    Sleep 100
    Loop
    Sleep 100
    myPDFCreator.cPrinterStop = False

    ' Wait until the PDF file shows up
    Do Until Dir(theFileRoot & outName) <> ""
    DoEvents
    Loop

    myPDFCreator.cClose
    Set myPDFCreator = Nothing
    Sleep 100
    DoEvents
    ActivePrinter = strOldPrinter
    End Sub

    Private Sub myPDFCreator_eError()
    MsgBox "ERROR [" & myPDFCreator.cErrorDetail("Number") & "]: " _
    & myPDFCreator.cErrorDetail("Description"), vbCritical + vbOKOnly, "PrtPDFCreator"
    End Sub

    Sub testPDFCreator()
    Dim mySheet As Worksheet

    For Each mySheet In ActiveWorkbook.Sheets
    mySheet.Activate
    Call PrtPDFCreator(mySheet)
    Next mySheet
    MsgBox "Done."
    End Sub

    --
    Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1