Setting Printing Options in VBA

katkth7533

New Member
Joined
Aug 18, 2014
Messages
14
Hi:

I was looking for some help in setting the print orientation and paper size for an excel document in VBA. This document is being used by multiple people and despite asking them no to change the printing options, they sometimes do. I have a code to print the file from another excel file and that code involved filtering the report before printing. The code is as follows:
Code:
Sub Set_Open_CentralTask8()
Dim wkb As Workbook

Application.ScreenUpdating = False
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
Set wkb = Workbooks.Open(Filename:="http://collabo/projects/DesignandConstructionProjectControls/Project Reporting/Development/Pipeline Reports/Central Region/Project_8.xlsm")

    With wkb.Sheets("TASKS")
        .Unprotect Password:="pipe"
        .Range("Ai7:Ai626").AutoFilter Field:=1, Criteria1:="FALSE"
        .Range("A1:I626").PrintOut Copies:=1
        .Range("Ai8:Ai626").AutoFilter
        .Protect Password:="pipe"
    End With

wkb.Close False
Application.ScreenUpdating = True

End Sub

I would like to add a Page Set-up option to this also, something along the lines of
Code:
With PageSetup
    .Orientation = xlLandscape
    .PaperSize = xlPaperA3
but I am not sure where to place these lines in the code without causing an error. I would also like the code to include a code to print the document on one side only (as opposed to 2 sided printing) but I am not sure how to do that.
Any ideas?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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