Hi,
Can you please make this code to be Sheet2 instead of the activewindow.
Thanks
![]()
ActiveWindow.SelectedSheets.PrintPreview
Hi,
Can you please make this code to be Sheet2 instead of the activewindow.
Thanks
![]()
ActiveWindow.SelectedSheets.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
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
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.
Oooops... I meant automatically closed the "Print Preview"
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.
Yes, i need the print preview to show then after a seconds will immediatelt hide it or close the print preview
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
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.
will you be able to rewrite the code?
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?
Ok.
What about print preview and close print preview sub macro vba code? This will probably work for me.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks