lemonhalls
Technical User
I have this code that is selecting only one page at a time.
I would like to apply this to the entire document, can someone please advice how would I change the code?
thanks
_______________________
Sub margin()
Dim myRange As Range
'moves the selection to the end
Selection.GoTo what:=wdGoToPage, Which:=wdGoToLast
'sets myRange to begin at first character in document and ends at the
'end of the first page
Set myRange = ActiveDocument.Range(Start:=0, End:=Selection.Range.End)
With myRange.ParagraphFormat
.LeftIndent = CentimetersToPoints(0.3)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With myRange.ParagraphFormat
.RightIndent = CentimetersToPoints(0)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
Selection.PageSetup.TopMargin = CentimetersToPoints(0.95)
ActiveWindow.ActivePane.VerticalPercentScrolled = 31
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.27)
Selection.EndKey Unit:=wdStory, Extend:=wdMove
End Sub
I would like to apply this to the entire document, can someone please advice how would I change the code?
thanks
_______________________
Sub margin()
Dim myRange As Range
'moves the selection to the end
Selection.GoTo what:=wdGoToPage, Which:=wdGoToLast
'sets myRange to begin at first character in document and ends at the
'end of the first page
Set myRange = ActiveDocument.Range(Start:=0, End:=Selection.Range.End)
With myRange.ParagraphFormat
.LeftIndent = CentimetersToPoints(0.3)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
With myRange.ParagraphFormat
.RightIndent = CentimetersToPoints(0)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
Selection.PageSetup.TopMargin = CentimetersToPoints(0.95)
ActiveWindow.ActivePane.VerticalPercentScrolled = 31
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.27)
Selection.EndKey Unit:=wdStory, Extend:=wdMove
End Sub