Excel PDF Macro Forcing First Page to be Portrait Mode?

pf_lav

New Member
Joined
Nov 13, 2022
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
Hi -
I am working on a macro that prints select sheets to a PDF output. For some reason, it will always print the first page in portrait mode even when I define in page setup to print it as landscape. If I put a page before it, that new first page will print as portrait and then my old "page 1" will print the correct way in landscape mode.
If I manually check the page setup, the page in question is in landscape mode, so I'm not sure how or why it's turning to portrait - and it seems to only affect the first page printed. When selecting which sheets to print, I use this array formula:

Dim arr() As String
Dim counter As Integer
ReDim Preserve arr(Sheets.Count - 5)
For i = 5 To Sheets.Count
arr(counter) = Sheets(i).Name
counter = counter + 1
Next i
Sheets(arr()).Select

Not sure if that might have any impact on the issue.

Does anyone have any experience with this or know how to fix it? Thank you!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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