+ Reply to Thread
Results 1 to 5 of 5

Print preview range with margins

Hybrid View

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Print preview range with margins

    Hi,

    When sample workbook is populated there will be date in columns A:G, I want to print a report that doesn't include irrelevant cells so would like to print range A7:G lastrow when the Print Report button is clicked.

    Currently I have this code that goes to print preview with the right range selected but when I close preview an error occurs saying that its a formula that starts with =/-

    Sub PreviewPrint()
    Dim VA As Worksheet
    Dim LastRow As Long
    
    
    
    Set VA = ThisWorkbook.Worksheets("Variances")
    
    LastRow = VA.Cells(Rows.Count, 1).End(xlUp).Row
    VA.PageSetup.PrintArea = VA.Range("A7:G" & LastRow).PrintPreview
    
    End Sub
    Basically looking for code that will print preview A7;G lastrow with narrow margins

    When I try recording a macro it comes back with

    Sub Macro4()
    '
    ' Macro4 Macro
    '
    
    '
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = "$A$1:$G$345"
        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 = xlPrintSheetEnd
            .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
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = "$A$1:$G$345"
        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 = xlPrintSheetEnd
            .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
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = "$A$1:$G$345"
        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 = xlPrintSheetEnd
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlPortrait
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 0
            .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
    Anyone got any ideas please.

    Down the line I would probably change print preview to direct printing if the right settings are default.

    Thanks
    Attached Files Attached Files
    Last edited by ~TaC~; 12-08-2020 at 06:17 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Print preview range with margins

    .
    Option Explicit
    
    Sub Macro4()
    '
    ' Macro4 Macro
    '
    
    '
        'Application.PrintCommunication = False
        'With ActiveSheet.PageSetup
        '    .PrintTitleRows = ""
        '    .PrintTitleColumns = ""
        'End With
        'Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = "$A$1:$G$345"
        '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 = xlPrintSheetEnd
            .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
        'Application.PrintCommunication = False
        'With ActiveSheet.PageSetup
        '    .PrintTitleRows = ""
        '    .PrintTitleColumns = ""
        'End With
        'Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = "$A$1:$G$345"
        '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 = xlPrintSheetEnd
            .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
        'Application.PrintCommunication = False
        'With ActiveSheet.PageSetup
        '    .PrintTitleRows = ""
        '    .PrintTitleColumns = ""
        'End With
        'Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = "$A$1:$G$345"
        '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 = xlPrintSheetEnd
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlPortrait
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 10
            .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
        Dim VA As Worksheet
        Set VA = ThisWorkbook.Worksheets("Variances")
        VA.PrintPreview
    End Sub

  3. #3
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Print preview range with margins

    Thanks, almost right result. this limits column G to row 345 where in OP I said I would like to print A7:G & lastrow (I forgot the &)

  4. #4
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Print preview range with margins

    Thought I fixed it but haven't.

    Changed code to:

    Sub Macro4()
    Dim VA As Worksheet
    Dim LastRow As Long
    
    
    
    Set VA = ThisWorkbook.Worksheets("Variances")
    
    LastRow = VA.Cells(Rows.Count, 1).End(xlUp).Row '
    ' Macro4 Macro
    '
    
    '
        'Application.PrintCommunication = False
        'With ActiveSheet.PageSetup
        '    .PrintTitleRows = ""
        '    .PrintTitleColumns = ""
        'End With
        'Application.PrintCommunication = True
        VA.PageSetup.PrintArea = VA.Range("A7:G" & LastRow).PrintPreview
        '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 = xlPrintSheetEnd
            .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
        'Application.PrintCommunication = False
        'With ActiveSheet.PageSetup
        '    .PrintTitleRows = ""
        '    .PrintTitleColumns = ""
        'End With
        'Application.PrintCommunication = True
        VA.PageSetup.PrintArea = VA.Range("A7:G" & LastRow).PrintPreview
        '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 = xlPrintSheetEnd
            .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
        'Application.PrintCommunication = False
        'With ActiveSheet.PageSetup
        '    .PrintTitleRows = ""
        '    .PrintTitleColumns = ""
        'End With
        'Application.PrintCommunication = True
        VA.PageSetup.PrintArea = VA.Range("A7:G" & LastRow).PrintPreview
        '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 = xlPrintSheetEnd
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlPortrait
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 10
            .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
    incorporating my original range code, previews the right data but when closing print preview shows following error

    Run-time error '1001:

    There's a problem with this formula.

    Not trying to type a formula?
    When the first character is an equal ("=") or minus ("-") sign, Excel
    thinks its a formula:
    •you type: =1+1. cell shows: 2

  5. #5
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Print preview range with margins

    Think I fixed it with this code

    Sub Macro9()
      Dim lr As Long
      lr = Range("A:G").Find("*", Range("A1"), , , xlByRows, xlPrevious, , , False).Row
      ActiveSheet.PageSetup.PrintArea = "A7:G" & lr
      ActiveSheet.PrintPreview
    
        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 = xlPrintSheetEnd
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlPortrait
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = False
            .FitToPagesWide = 1
            .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
    Print previews required columns to last row with narrow margins so all nearly good however when I close the print preview box the system goes to 'not responding' for a few seconds and then recovers. Is this normal or error in code?

+ 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. Print preview margins don't match printout
    By boborr in forum Excel General
    Replies: 0
    Last Post: 03-05-2013, 01:56 PM
  2. macro to adjust print margins in print preview mode
    By yeoye in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2009, 06:16 AM

Tags for this Thread

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