Print size change using VBA.

imback2nite

Board Regular
Joined
Oct 30, 2004
Messages
209
Office Version
  1. 2003 or older
Platform
  1. Windows
I'm hoping this is a stupid question. I use the code below to print a page. The problem is when I print to pdf, it comes out fine. Even when I print the pdf file. When I print to paper the print range I set is not used. The page prints twice the size in width. What am I doing wrong? Thank you in advance.

Rich (BB code):
Private Sub CommandButton4_Click()
    Application.ScreenUpdating = False
   YesNo = MsgBox("This Action Will Print, 'Tally Sheet'      " & vbCr _
    & "                   Continue?", vbYesNo + vbInformation, "Caution")
    Select Case YesNo
    Case vbYes
    With ActiveSheet.PageSetup
        .PrintTitleRows = "$1:$19"
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = "$B$1:$N$319"
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = "&""Tahoma,Bold""CONFIDENTIAL"
        .RightHeader = ""
        .CenterFooter = "Page &P of &N"
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0#)
        .RightMargin = Application.InchesToPoints(0#)
        .TopMargin = Application.InchesToPoints(0.5)
        .BottomMargin = Application.InchesToPoints(0.5)
        .HeaderMargin = Application.InchesToPoints(0.25)
        .FooterMargin = Application.InchesToPoints(0.25)
        .CenterHorizontally = True
        .Orientation = xlPortrait
        .Zoom = 52
        .Draft = False
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    Range("B1").Select
     Application.ScreenUpdating = True
Case vbNo
    Application.ScreenUpdating = False
    Range("B1").Select
    Application.ScreenUpdating = True
    End Select
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,221,531
Messages
6,160,367
Members
451,642
Latest member
mirofa

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