+ Reply to Thread
Results 1 to 12 of 12

Printpreview

Hybrid View

RJ1969 Printpreview 04-09-2019, 05:57 PM
RJ1969 Re: Printpreview 04-09-2019, 06:24 PM
RJ1969 Re: Printpreview 04-09-2019, 06:52 PM
RJ1969 Re: Printpreview 04-09-2019, 09:05 PM
RJ1969 Re: Printpreview 04-09-2019, 09:10 PM
scottiex Re: Printpreview 04-09-2019, 09:28 PM
RJ1969 Re: Printpreview 04-09-2019, 09:55 PM
RJ1969 Re: Printpreview 04-09-2019, 10:03 PM
scottiex Re: Printpreview 04-09-2019, 10:06 PM
RJ1969 Re: Printpreview 04-09-2019, 10:09 PM
scottiex Re: Printpreview 04-09-2019, 10:14 PM
RJ1969 Re: Printpreview 04-09-2019, 10:22 PM
  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Printpreview

    Hi,
    Can you please make this code to be Sheet2 instead of the activewindow.

    Thanks

    ActiveWindow.SelectedSheets.PrintPreview

  2. #2
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    Hi,
    I want the printpreview for Sheet2 instead the activewindow.
    If the code can printpreview Sheet2 and close then after as a macro.

    Thanks.

    Sub Margins()
    With Worksheets("Sheet2").PageSetup
            .Zoom = 78
            .LeftHeader = ""
            .CenterHeader = "Misdemeanor Matrix April 2019"
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = "Page &P of &N"
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0)
            .RightMargin = Application.InchesToPoints(0.25)
            .TopMargin = Application.InchesToPoints(0.5)
            .BottomMargin = Application.InchesToPoints(0)
            .HeaderMargin = Application.InchesToPoints(0.3)
            .FooterMargin = Application.InchesToPoints(0.3)
            .PrintHeadings = False
            .PrintGridlines = False
            .PrintComments = xlPrintNoComments
            .PrintQuality = 600
            .CenterHorizontally = True
            .CenterVertically = False
            .Orientation = xlPortrait
            .Draft = False
            .PaperSize = xlPaperLetter
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            '.Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = 1
            .PrintErrors = xlPrintErrorsDisplayed
        End With
        ActiveWindow.SelectedSheets.PrintPreview
    End Sub

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    Hello,
    This is what I came out with a code and it works for me but I need to add a code "close print preview".

    End With
        With Worksheets("Sheet2").PrintPreview
        End With
    End Sub

  4. #4
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    Let me clarify, maybe it will help the issue.

    I want the print preview in Sheet2 to wait for a 2 seconds then it will manually closed the print preview.

    Please if you can write some code to be added on this:

    End With
    With Worksheets("Sheet2").PrintPreview
    End With
    End Sub

    Thank you.

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    Oooops... I meant automatically closed the "Print Preview"

  6. #6
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Printpreview

    Print preview suspends the code. So this is at least not a simple request, you may get no answer.

    Why do you want to do this anyway?
    You seem to be asking to show the print preview then immediately hide it?
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    Yes, i need the print preview to show then after a seconds will immediatelt hide it or close the print preview

  8. #8
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    This is what I have so far but Its not working.
    There is a 2 seconds but it does not automatically kill the preview.


    Sub Margins()
    With Worksheets("Sheet2").PageSetup
        .Zoom = 77
        .CenterHeader = "Matrix APRIL 2019"
        .CenterFooter = "Page &P of &N"
        .HeaderMargin = Application.InchesToPoints(0.03)
        .FooterMargin = Application.InchesToPoints(0.03)
        .BottomMargin = Application.InchesToPoints(0)      'Set the bottom margin to .5 inches
        .LeftMargin = Application.InchesToPoints(0)     'Set the left margin to 3/4 of inch
        .RightMargin = Application.InchesToPoints(0.25)
        .TopMargin = Application.InchesToPoints(0.5)
        .Orientation = xlPortrait     'Change this constant to xlLandscape to print in landscape
        .Order = xlDownThenOver    'Controls how pages are numbered and printed out
    End With
    Application.OnTime Now + TimeValue("00:00:02"), "KillPreview"
    With Worksheets("Sheet2").PrintPreview
    SendKeys ("{ESC}")
    End With

  9. #9
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Printpreview

    Yes, that is what I was saying,

    I think you will find With Worksheets("Sheet2").PrintPreview stops your code.
    As a result you never get to the next line where you are trying to send keys "escape". Not easy to get around.

  10. #10
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    will you be able to rewrite the code?

  11. #11
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Printpreview

    unless someone else has an idea -

    Maybe take a step back and think why you need this to happen.

    Maybe you just need to see the page layout or the page break preview or something like that?

  12. #12
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Printpreview

    Ok.
    What about print preview and close print preview sub macro vba code? This will probably work for me.

+ 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. PrintPreview
    By oddbjorn-j in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2017, 10:56 AM
  2. Printpreview
    By Manvinder8 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-21-2010, 12:15 AM
  3. Excel Hangs When PrintPreview
    By tqm1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2007, 08:43 AM
  4. Print or PrintPreview
    By bhofsetz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-16-2007, 07:03 PM
  5. [SOLVED] PrintPreview Error
    By AM_137 in forum Excel General
    Replies: 0
    Last Post: 04-03-2006, 03:00 PM
  6. printpreview
    By Alex in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2005, 06:05 PM
  7. PrintPreview Zoom
    By CG Rosén in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2005, 12: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