Results 1 to 3 of 3

Set size to A4, orientation to landscape and margins to narrow and then Save As PDF

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-30-2018
    Location
    Sweden
    MS-Off Ver
    2016.
    Posts
    397

    Set size to A4, orientation to landscape and margins to narrow and then Save As PDF

    Hi, I am trying to save a report as PDF and I have searched and found a couple of threads but none that works.

    I would like to set the size to A4, the orientation to landscape and the margins to narrow and then Save As PDF.

    I have recorded a macro where I do this and perhaps someone can help me adapt it?

    Sub SaveAsPDF()
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = ""
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0.7)
            .RightMargin = Application.InchesToPoints(0.7)
            .TopMargin = Application.InchesToPoints(0.75)
            .BottomMargin = Application.InchesToPoints(0.75)
            .HeaderMargin = Application.InchesToPoints(0.3)
            .FooterMargin = Application.InchesToPoints(0.3)
            .PrintHeadings = False
            .PrintGridlines = False
            .PrintComments = xlPrintNoComments
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlLandscape
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = 100
            .PrintErrors = xlPrintErrorsDisplayed
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
            .EvenPage.LeftHeader.Text = ""
            .EvenPage.CenterHeader.Text = ""
            .EvenPage.RightHeader.Text = ""
            .EvenPage.LeftFooter.Text = ""
            .EvenPage.CenterFooter.Text = ""
            .EvenPage.RightFooter.Text = ""
            .FirstPage.LeftHeader.Text = ""
            .FirstPage.CenterHeader.Text = ""
            .FirstPage.RightHeader.Text = ""
            .FirstPage.LeftFooter.Text = ""
            .FirstPage.CenterFooter.Text = ""
            .FirstPage.RightFooter.Text = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "here I want to insert a dynamic workbook name from cell B1" _
            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
            :=False, OpenAfterPublish:=True
    End Sub
    FileName:=
    Is where I need help? I would like to save as PDF without notification and to a dynamic PDF name but I am not sure how to?
    Last edited by waimea; 12-27-2018 at 10:13 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Print Orientation from Portrait to landscape?
    By bralew in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2017, 07:20 AM
  2. Save Excel Charts to PDF in Landscape Orientation and Fit Page
    By huntethic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2017, 05:55 PM
  3. Set Margins to Narrow
    By fazthfc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2015, 06:01 AM
  4. Setting Margins to Narrow in Word before copying table
    By ERaasio in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2013, 11:26 AM
  5. Print Macro - Landscape Orientation Graph
    By Oliver Rogers in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-28-2011, 07:37 AM
  6. Trouble with landscape page orientation
    By barbinhb in forum Excel General
    Replies: 2
    Last Post: 03-11-2010, 04:17 PM
  7. landscape and letter orientation same doc?
    By godfather_77 in forum Word Formatting & General
    Replies: 1
    Last Post: 02-22-2009, 07:59 AM

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