Print selected Range one time but vertically(portrait)?

ljubo_gr

Active Member
Joined
Dec 6, 2014
Messages
251
Office Version
  1. 2013
Platform
  1. Windows
Hello dear MrExcel!

How to print selected range vertically, copies 1, colatte True, normal margins?
Thanks in advance?
Ps. I just don't know very well VBA, sorry for SELECT&SELECTION!

Code:
Sub Macro1printanjestanja()
'
' Macro1printanjestanja Macro
'
'
'    Range("M8:Q22").Select
'    Selection.PrintOut Copies:=1, Collate:=True, Orientation = xlLandscape
'    Range("A1").Select
'End Sub

        Dim DP As Dialog
        On Error GoTo Greh
        Application.ScreenUpdating = False
'                 Run ([Macro1_OZNACI_stanje()])
        Set DP = Application.Dialogs(xlDialogPrinterSetup)
        With DP
            If .Show = -1 Then
                ThisWorkbook.Worksheets(".....IZVJEŠTAJ").Range("M8:Q22").PrintOut Copies:=1, _
                Collate:=True, Preview:=False
                ThisWorkbook.Worksheets(".....IZVJEŠTAJ").Range("A1").Select
            End If
        End With
Greh:
    Exit Sub
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I ended up with macro recorder, and result is:
Code:
Sub Macro1PrintanjeStanja()
'
' Macro1printanjestanja Macro
'
'
        Dim DP As Dialog
        On Error GoTo Greh
        Application.ScreenUpdating = False
        Set DP = Application.Dialogs(xlDialogPrinterSetup)
        With DP
            If .Show = -1 Then
                    Application.PrintCommunication = False
                    With ActiveSheet.PageSetup
                        .LeftHeader = ""
                        .CenterHeader = ""
                        .RightHeader = ""
                        .LeftFooter = ""
                        .CenterFooter = ""
                        .RightFooter = ""
                        .LeftMargin = Application.InchesToPoints(0.708661417322835)
                        .RightMargin = Application.InchesToPoints(0.708661417322835)
                        .TopMargin = Application.InchesToPoints(0.748031496062992)
                        .BottomMargin = Application.InchesToPoints(0.748031496062992)
                        .HeaderMargin = Application.InchesToPoints(0.31496062992126)
                        .FooterMargin = Application.InchesToPoints(0.31496062992126)
                        .PrintHeadings = False
                        .PrintGridlines = False
                        .PrintComments = False
                        .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
                ThisWorkbook.Worksheets(".....IZVJEŠTAJ").Range("M8:Q22").PrintOut Copies:=1, _
                Collate:=True, Preview:=False
                ThisWorkbook.Worksheets(".....IZVJEŠTAJ").Range("A1").Select
            End If
        End With
Greh:
    Exit Sub
End Sub
Now i have problem, similar code for saving in .pdf, but problem is when pdf is saved it is instatlly opened but without focus. Focus is on excel, how to change focus to that new opened file?
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top