#1
|
|||
|
|||
What's wrong with my loop?
Hi,
I am getting multiple footers in sections. Does anybody know what I am going wrong? Sub AddFooter() ' ' AddFooter Macro ' ' Dim i As Integer ActiveDocument.PageSetup.OddAndEvenPagesHeaderFoot er = True For i = 1 To ActiveDocument.Sections.Count ActiveDocument.Sections(i).Footers(wdHeaderFooterP rimary).Range _ .InsertAfter "Odd Header" ActiveDocument.Sections(i).Footers(wdHeaderFooterE venPages).Range _ .InsertAfter "Even Header" Next i End Sub Please help.Thank you!!! |
#2
|
|||
|
|||
There is nothing wrong with your loop as it is doing exactly what you are telling it to do.
Word headers and footers are sort of like the old player piano sheets that form a continuous loop that repeats over an over again. Unless you break the link between new sections when you add them the contents will just keep piling up. Unless broken the first section header is sort of linked to the last section header. Code:
Sub AddFooter() Dim i As Integer ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = True For i = 1 To ActiveDocument.Sections.Count ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).LinkToPrevious = False ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).Range.InsertAfter "Odd Footer Section " & i ActiveDocument.Sections(i).Footers(wdHeaderFooterEvenPages).LinkToPrevious = False ActiveDocument.Sections(i).Footers(wdHeaderFooterEvenPages).Range.InsertAfter "Even Footer Section " & i Next i End Sub |
#3
|
|||
|
|||
Still not working
Thank you very much gmaxey... It is still not doing what I want. It is still adding multiple footers to sections...
My last footer (last section) looks like this: Even Footer Section 3Even Footer Section 4Even Footer Section 5Even Footer Section 6Even Footer Section 7Even Footer Section 8Even Footer Section 9Even Footer Section 10Even Footer Section 11Even Footer Section I am sure my script has a flaw but I can't find it . Please help! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
First 5 slides in a loop | Joop | PowerPoint | 0 | 05-06-2014 09:30 AM |
End or alter a loop? | DJSOUND | Word VBA | 1 | 10-11-2013 08:11 PM |
How to a For loop in VBA | Jennifer Murphy | Word VBA | 1 | 01-29-2013 03:30 AM |
While loop not working right | Cbrehm | Excel Programming | 0 | 05-11-2011 11:05 AM |
Continuous Loop | cksm4 | Word | 6 | 01-06-2011 09:03 PM |