Fi69
asked on
Word VBA Inserting Section Break for Landscape Page
I'm only new to VBA. I am trying to insert a Landscape Page into my Word document by VBA code. It inserts the page fine but I've noticed that it is applying the style "footer landscape" style to the page before it (that is before the section break) as well . Does anyone know what I've done wrong and how to isolate the footer change to just the new section?? I'm hoping for a very quick reply.
Sub InsertLandscape()
Application.ScreenUpdating = False
ActiveDocument.Range(Start:=Selection.Start, End:=Selection.Start). _
InsertBreak Type:=wdSectionBreakNextPage
Selection.Start = Selection.Start + 1
With ActiveDocument.Range(Start:=Selection.Start, End:=ActiveDocument. _
Content.End).PageSetup
.TextColumns.SetCount NumColumns:=1
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(0.9)
.BottomMargin = CentimetersToPoints(1.7)
.LeftMargin = CentimetersToPoints(2)
.RightMargin = CentimetersToPoints(2)
.HeaderDistance = CentimetersToPoints(0.3)
.FooterDistance = CentimetersToPoints(0.6)
.DifferentFirstPageHeaderFooter = False
End With
ActiveDocument.AttachedTemplate.AutoTextEntries("FooterLandscape").Insert _
Where:=ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range, RichText:=True
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Style = "Footer Landscape"
Application.ScreenUpdating = True
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.