Results 1 to 5 of 5

Thread: How to avoid print dialog box?

  1. #1

    How to avoid print dialog box?

    Hi,
    I am trying to automate the steps required to convert a worksheet into a pdf document. I am using the following code. The code works fine if I eliminate ?prtofilename:=Filename? from the parameters for the Printout method. But then a print dialog box pops up, where I have to enter a filename for the file being saved. I want to avoid this step. I tried different ways but couldn?t achieve this. Could you suggest a solution?

    Sub print_macro()
     
    Dim Filename As String
    Filename = "c:\ABC.pdf"
     
    Application.ActivePrinter = "CutePDF Writer on CPW2:"
     
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
      "CutePDF Writer on CPW2:", PrintToFile:=False, Collate:=True, prtofilename:=Filename
     
    End Sub
    System: Windows XP
    Excel 2003 Sp2

    Thanks,

    MG.

  2. #2
    VBAX Expert
    Joined
    Feb 2005
    Location
    Nanaimo, British Columbia, Cananda
    Posts
    568
    Location
    Hi MG, Did you try changing PrintToFile:=True ?
    [VBA]
    Sub print_macro()

    Dim Filename As String
    Filename = "c:\ABC.pdf"

    Application.ActivePrinter = "CutePDF Writer on CPW2:"

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
    "CutePDF Writer on CPW2:", PrintToFile:=True, Collate:=True, prtofilename:=Filename

    End Sub
    [/VBA]
    Cheers,

    dr

    "Questions, help and advice for free, small projects by donation. large projects by quote"

    http:\\www.ExcelVBA.joellerabu.com

  3. #3
    rbrhodes,

    Thanks. I had tried that option before, and the printing seemed automatic (with no Save As box appearing); however, the pdf file created by the code was corrupt. Adobe Acrobat was not able to open those files. I figured that may be there was something wrong with the vba code.

    Thanks,
    MG.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,478
    Location
    You can modify registry settings to automate Cute PDF printing. See here
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    mdmackillop,

    Thanks.

    1. I have a free version of Cutepdf. Do those registry edits work with the free version?

    2. I tried to do the changes suggested by the document on Cutepdf's website using Regedit, but couldn't find those particular variables ( e.g. BypassSaveAs).


    Thanks,

    MG.

Posting Permissions

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