Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Print to pdf using Macro

  1. #1
    Join Date
    4th October 2005
    Posts
    41

    Print to pdf using Macro

    Dear Expert,

    I would like to have a macro button on Sheet1 and the function of this button is to print Sheet2 to pdf. Can anyone please help to configure the macro?

    Please help!

    Regards,
    Serenapoh

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    22nd January 2004
    Location
    Colorado Springs
    Posts
    4,026

    Re: Print to pdf using Macro

    serenapoh,


    I'm assuming that you're asking because you all ready HAVE that ability on your PC.

    If so why not record the actions that you need to take and then use/modify that macro to fit your specific needs. I don't have that ability on my pc so it must be something that is specific to your setup.
    Regards,
    Barry

    My Favorite New Thing:
    Dynamic Named Ranges



    The alternative for
    "Press Any Key To Continue."

    and we all have one we'd like to use it on


    1. Cross Posting Etiquette
    2. Are You Here To Learn: What Have You Tried?
    3. Your Best Resource to begin learning VBA: RECORD A MACRO . . . Then Study It!

  3. #3
    Join Date
    28th January 2003
    Location
    Solihull - England
    Posts
    8,678

    Re: Print to pdf using Macro

    I think the user might be using Acrobat distiller.... Is this the case serenapoh ?

    If so, I posted some code up a while back that I had adapted from the web

    http://www.ozgrid.com/forum/showthread.php?t=25773
    Kind Regards, Will Riley

    Web Presence:
    LinkedIn: Will Riley

  4. #4
    Join Date
    4th October 2005
    Posts
    41

    Re: Print to pdf using Macro

    Thank you for the advice.
    I do not have Acrobat distiller. May I know how should I download it?

    I have downloaded and installed PrimoPDF (freeware) which enable me to print Excel worksheet to PDF. What I have to do is just click on File-Print-Select Printer as PrimoPDF.

    The freeware can be downloaded from
    http://www.snapfiles.com/get/primopdf.html


    My problem is to configure a button in Sheet1 to print Sheet2 to PDF by just clicking on the button.

    Please help.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    28th January 2003
    Location
    Solihull - England
    Posts
    8,678

    Re: Print to pdf using Macro

    Acrobat Distiller is part of Adobe Acrobat (full version) - it costs $$ so you can't just download it

    As for your freeware, without having a play around with it i'm not sure. If I get time later, I will take a look at it from home.
    Kind Regards, Will Riley

    Web Presence:
    LinkedIn: Will Riley

  6. #6
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    18,435

    Re: Print to pdf using Macro

    The simplest way to achieve this is to use the print dialog
    VB:
    Application.Dialogs(xlDialogPrint).Show 
    
    
    The pdf writer will appear in the Printer dropdown and you can then create your pdf
    Hope that Helps

    Roy

    For free Excel tools & articles visit my web site

    If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

  7. #7
    Join Date
    4th October 2005
    Posts
    41

    Re: Print to pdf using Macro

    Many thanks for the advice. It works!!!

    Is it possible to print Sheet 2 when the print button is on Sheet 1.
    Can it be coded to set the printer to PrimoPDF and click OK button automatically (which means that the print window does not appear on the screen)?

    Please help!!!

    Excel Video Tutorials / Excel Dashboards Reports


  8. #8
    Join Date
    22nd January 2004
    Location
    Colorado Springs
    Posts
    4,026

    Re: Print to pdf using Macro

    serenopah,

    Like I stated in the first reply in this thread. Try recording a macro while you do the steps required to print using the pdf in your print menu.

    Excel should record all the steps. If we don't have the software, and are not willing to install it, then you will need to record it and either post it asking how to alter it or use it as is.
    Regards,
    Barry

    My Favorite New Thing:
    Dynamic Named Ranges



    The alternative for
    "Press Any Key To Continue."

    and we all have one we'd like to use it on


    1. Cross Posting Etiquette
    2. Are You Here To Learn: What Have You Tried?
    3. Your Best Resource to begin learning VBA: RECORD A MACRO . . . Then Study It!

  9. #9
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    18,435

    Re: Print to pdf using Macro

    Try this, change the sheet that i have specified to suit your needs
    VB:
     '---------------------------------------------------------------------------------------
     ' Module    : Module2
     ' DateTime  : 31/10/2005 19:40
     ' Author    : Roy  Cox
     ' Website   : [url]www.excel-it.com[/url]
     ' Purpose   : automate pdf with PrimoPDF
     '---------------------------------------------------------------------------------------
    Option Explicit 
     
    Sub PrintToPrimoPDF() 
        Dim strCurrentPrinter As String 
        strCurrentPrinter = Application.ActivePrinter ' save the currently active printer
        On Error Resume Next ' ignore  errors
        Application.ActivePrinter = "PrimoPDF on Ne04:" ' change to PrimoPdf
        Sheet1.PrintOut ' print the sheet1
        Application.ActivePrinter = strCurrentPrinter ' change back to the original printer
        On Error Goto 0 ' resume normal error handling
    End Sub 
    
    
    Hope that Helps

    Roy

    For free Excel tools & articles visit my web site

    If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

  10. #10
    Join Date
    4th October 2005
    Posts
    41

    Re: Print to pdf using Macro

    Thanks a lot!!!

    However, I would like to put the button on Sheet1 to configure printing job for Sheet2. It doesn't work even when I change this:

    VB:
    Sheet2.PrintOut ' print the sheet2
    
    

    Please help!

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Disable Print But Allow Print From Macro
    By sujittalukder in forum EXCEL HELP
    Replies: 9
    Last Post: June 11th, 2007, 21:43
  2. Stop Print Macro Firing Before Print Event
    By Gon in forum EXCEL HELP
    Replies: 16
    Last Post: October 19th, 2006, 16:05
  3. VBA Macro - Print page set print area
    By geo_glitche in forum EXCEL HELP
    Replies: 2
    Last Post: December 31st, 2005, 10:28
  4. Print macro
    By sginther in forum EXCEL HELP
    Replies: 3
    Last Post: April 6th, 2005, 05:38
  5. Print Macro
    By tratliff in forum EXCEL HELP
    Replies: 1
    Last Post: August 25th, 2004, 06:24

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
  •  
porno