View Single Post
 
Old 08-26-2020, 06:54 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

As I said earlier, if the document contains a section break then there could be more than one orientation in the document and you would need to treat each section individually. lngOrient would be undefined if there is a mix of orientation.

Code:
Sub Resize(oDoc As Document)
  Dim lngOrient As Long, aSect As Section
  For Each aSect In oDoc.Sections
    With aSect.PageSetup
      lngOrient = .Orientation
      If .PaperSize = wdPaperLetter Then
        .PaperSize = wdPaperA4
        .Orientation = lngOrient
      End If
    End With
  Next aSect
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote