Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Excel VBA Print to PDF

  1. #1
    Join Date
    31st May 2011
    Posts
    54

    Excel VBA Print to PDF

    Hi,

    I am trying to write a macro that prints the active sheet to a pdf file automatically.

    Here is the code Im using:

    VB:
    Sub PrintPDF() 
        Application.ScreenUpdating = False 
        Sheets("Sheet1").PrintOut Copies:=1, _ 
        ActivePrinter:="CutePDF Writer on CPW2:", PrintToFile:=True, _ Collate:=True,PrToFileName:=ModifiedSheet1.pdf 
        Application.ScreenUpdating = False 
    End Sub 
     
    This prints a pdf Like I want but I get an error when I try To Open the pdf. 
     
    If I leave the code Like this: 
    Sub PrintPDF() 
        Application.ScreenUpdating = False 
        Sheets("Sheet1").PrintOut Copies:=1, _ 
        ActivePrinter:="CutePDF Writer on CPW2:", Collate:=True 
        Application.ScreenUpdating = False 
    End Sub 
    
    
    It just brings up the save as dialog box and then I have to manually type in the filename, but I can open the pdf after this method.

    Am I missing something in the first method? It would be very helpful to not have to manually type in the filename every time (that's why I wrote the macro in the first place).

    Thanks,

    Craig
    Last edited by Reafidy; June 25th, 2011 at 07:31.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    31st May 2011
    Posts
    54

    Re: Excel VBA Print to PDF

    After doing a little more digging I found another person with the same issue.

    http://www.excelforum.com/excel-prog...-with-vba.html

    However I'm still unable to find a simple answer. =\

    Craig

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    31st May 2011
    Posts
    54

    Re: Excel VBA Print to PDF

    I'm still confused as to why I am having problems with the PrToFileName parameter.

    I have tried leaving out the .pdf at the end of the PrToFileName variant however an extension-less file is created which is not helpful.

    Is anyone even able to reproduce this error?

    I'm using excel 2007 and CutePDF Writer

    Thanks,

    Craig

    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. Excel Print problem
    By sadams in forum EXCEL HELP
    Replies: 9
    Last Post: June 5th, 2003, 23:42
  2. can i able to print all the excel formula's
    By s_u_resh in forum EXCEL HELP
    Replies: 16
    Last Post: February 22nd, 2003, 06:46

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