+ Reply to Thread
Results 1 to 3 of 3

Set Margins to Narrow

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Set Margins to Narrow

    Hi all,

    I am trying to add a code to set the printing margins to narrow. I have recorded a Macro which gives the following code:

    Sub PageMarginsNarrow()
    '
    ' PageMarginsNarrow Macro
    ' Change margin size to narrow
    '

    '
    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.25)
    .RightMargin = Application.InchesToPoints(0.25)
    .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
    .PrintQuality = Array(600, 300)
    .CenterHorizontally = False
    .CenterVertically = False
    .Orientation = xlPortrait
    .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
    End Sub

    However whenever I run this sub the printing margins remain the same.

    Is there anything wrong with the code?

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Set Margins to Narrow

    Hello,

    this code works for me...(on the active sheet)
    (you don't need all the extra lines)
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Registered User
    Join Date
    07-16-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    25

    Re: Set Margins to Narrow

    Works perfectly. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to narrow down results??
    By BernardKF in forum Excel General
    Replies: 4
    Last Post: 05-07-2014, 10:11 AM
  2. 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
  3. Looking for Lotto narrow down system
    By Larbec in forum Excel General
    Replies: 1
    Last Post: 04-30-2013, 12:23 PM
  4. narrow down to last character in cell
    By kuder in forum Excel General
    Replies: 3
    Last Post: 10-24-2011, 02:35 PM
  5. [SOLVED] Too narrow columns
    By Sige in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-12-2005, 11:05 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