PDA

View Full Version : Solved: Section Header/Footer problem



ukemike
08-15-2005, 11:07 AM
Hey guys,
Its me again. This problem i couldnt solve myself.

If i create a blank word document. Then insert three section breaks (Section Next Page) and then go to the header of Section1 and write S1 there,
go to the header of Section2 and write S2 and turn off Link To Previous, then go to section 3 and write S3 and turn off Link to Previous.
Why is it when i set the third section's header to S3 the second section's header also has S3? Even thought i turned off the Link To Previous in all the sections? Is there something else i should know on how to make each section's header/footer separate from each other?


Thanx
Mike

fumei
08-15-2005, 11:26 AM
It is the order you are doing things. And it can get much worse if you start using DifferentFirstpage, or DifferentOddEven,

You need to change Link to Previous before you enter the text.

Steps that actually happened.

1. type in Sec 2 "S2", Section header text = "S2"
2. go to Sec 3 ( it IS LinkToPrevious = True)
3. type in Sec 3 "S3". as LinkToPrevious = True...Sec 2 immediately becomes "S3" because you are in fact EDITING Sec 2 header.
4. make Sec 3 LinkToPrevious = False does separate Sec 3 header from Sec 2, BUT....Sec 2 was already changed to "S3"

ukemike
08-15-2005, 11:58 AM
Thanks for your help.
There is no one option you can set per document that would make all the LinkToPrevious false automatically?


Mike

MOS MASTER
08-15-2005, 12:04 PM
Thanks for your help.
There is no one option you can set per document that would make all the LinkToPrevious false automatically?


Mike

Nopes there isn't! :yes You have to do it every time you add a section..

fumei
08-15-2005, 12:24 PM
This is one of the useful things about VBA. I will NEVER make a new section using the menu Insert > Break, and say, Section Break Next Page.

I make all of my section breaks by VBA, explicitly setting LinkToPrevious = False. Plus I always create the other headers (footers) for FirstPage and Odd/Even immediately. Even if I do not have pages for them yet. These are also explicitly set LinkToPrevious = False. Unless the design of the document explicitly does not require LinkToPrevious = False. for example, on the opening page of each chapter I do NOT want a header at all. So, for those type of documents (created from a template), the section making code makes a new section (chapter), set FirstPage to "", or nothing - keeping as LinkToPrevious = True, sets Primary and DifferentOddEven to False and insert appropriate text.

The bottom line is: LinkToPrevious = True is the default.

Or put another way:
With .Sections(1).Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
.Range.Text = "S3"
End With

gives a different result than:
With .Sections(1).Headers(wdHeaderFooterPrimary)
.Range.Text = "S3"
.LinkToPrevious = False
End With

MOS MASTER
08-16-2005, 10:27 AM
Mike..did it work out for yah? :yes

ukemike
08-16-2005, 10:35 AM
Hey guys sorry I didnt respond. I just figured out what the problem was. My section headers/footers were working fine (Its always something other than what you think).

What was happening was that. Let me just rundown what i am doing (for those that didnt read my previous posts). I am opening up a word document throught a c# app and then using VBA find/replace to replace fields. After that document is done i use InsertFile and insert another copy of the document to a new page and do the same thing. The data that is put in is different for each template, obviously. So each time i insert a the template i create a new section in the word document. This way i can have a different header for each section and page each section property even though its a one document.

The problem was that at the end of my template i had a bookmark "End". And after I was done doing all the find/replace i jumped to this bookmark before inserting a new template. Well I forgot to erase this bookmark for each one of the templates that are FINISHED. So when i inserted a new template and did all the find/replace and the tried to jump to "End", It would just to the "End" bookmark of the previous template (previous section).

Thank you very much guys. I cant believe this stupid little problem took me so long to figure out.


Mike:bow:

MOS MASTER
08-16-2005, 10:37 AM
Hi Mike, :yes

Interesting story..such things happen to all of us!

Glad you solved it..could you mark the thread solved as well? :whistle: