Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-24-2018, 07:05 PM
KevinRS KevinRS is offline Script to add page has footer problems Windows 10 Script to add page has footer problems Office 2016
Novice
Script to add page has footer problems
 
Join Date: Dec 2018
Posts: 1
KevinRS is on a distinguished road
Default Script to add page has footer problems

Hi,

Working with VBA on Word files that already has footer styles to accommodate pages of various sizes. My goal is to provide a VBA script that does the following in an 8.5X11 portrait-oriented document with footers:

1) Adds a section break followed by an 11X17 landscape page.
2) Applies a pre-existing style (Footer17) to that page.

I am a VBA novice, and every attempt I have made so far results in sizing issues for the other footers, or runs correctly in Debug mode but fails in real time. Any help would be appreciated, and I will be happy to provide any information that will help resolving this issue. Thanks!

Here's my code so far:

Sub Add11X17Landscape()
'
' Add11X17Landscape Macro

Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.TypeText Text:="Inserted New Page"
Selection.TypeParagraph
Selection.TypeParagraph
Selection.InsertBreak Type:=wdSectionBreakNextPage

Selection.TypeParagraph
With Selection.Find
.Text = "Inserted New Page"
.Wrap = wdFindContinue


End With
If Selection.Find.Execute = True Then
With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.4)
.PageWidth = InchesToPoints(11)
.PageHeight = InchesToPoints(17)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
If Selection.PageSetup.Orientation = wdOrientPortrait Then
Selection.PageSetup.Orientation = wdOrientLandscape
Else
Selection.PageSetup.Orientation = wdOrientPortrait
End If
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If

' The script fails in this section. I also need to ensure that the footer in the page prior to the 11X17 page is marked "LinkToPrevious"

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
' New 11X 17 page
Selection.HeaderFooter.LinkToPrevious = False

ActiveWindow.ActivePane.View.SeekView = wdSeekNextPageFooter
' Page following the 11X17
Selection.HeaderFooter.LinkToPrevious = False

ActiveWindow.ActivePane.View.PreviousHeaderFooter
' back to the new11X17 page
Selection.WholeStory
Selection.Style = ActiveDocument.Styles("Footer17")

End If
End Sub
Reply With Quote
  #2  
Old 12-25-2018, 02:59 AM
macropod's Avatar
macropod macropod is offline Script to add page has footer problems Windows 7 64bit Script to add page has footer problems Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See: http://www.vbaexpress.com/forum/show...l=1#post354835
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
footers, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
I have 20 page word document with a footer. Can i change page # 10 footer only? aligahk06 Word 2 10-25-2017 04:53 AM
Script to add page has footer problems Some problems in this script eduzs Word VBA 4 05-17-2017 04:14 PM
Script to add page has footer problems Having a lot of header/footer problems blockie Word 3 08-22-2014 05:50 PM
Script to add page has footer problems begin each section with page 1 in header PLUS continuous page numbering in footer onemorecupofcoffee Word 18 09-04-2013 04:31 PM
header/footer problems only in certain documents Endzone Word 5 08-15-2012 01:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft