Thread: MS Word Macro
View Single Post
 
Old 06-17-2015, 04:22 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I'm not trying to play "I can write that code in # lines or less" ;-). Just curious and would like comment on advantages/disadvantages (if either) of using defined variables such as oDoc in this case and explicitly setting objects (oSection) to nothing when it appears that oSection is set to nothing automatically anyway.

Code:
Sub FixMarginII()
Dim oSection As Section
  With ActiveDocument
    If .Sections(1).PageSetup.PaperSize = wdPaperA4 Then
      For Each oSection In .Sections
        If oSection.PageSetup.Orientation = wdOrientLandscape Then
          oSection.PageSetup.LeftMargin = InchesToPoints(1.8)
        End If
      Next oSection
      .Save
    End If
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote