PDA

View Full Version : Split Word Document By Header



fungus1487
02-03-2010, 04:02 AM
Hi Everyone,

I have been racking my brains a bit for the answer to this.
I have been using the great example for splitting word documents based on a given string at http : // www .vbaexpress.com /kb/getarticle.php?kb_id=922 (sorry can't post link) but can't figure out how to tweak it for my needs.
Hopefully someone can help.

The requirement is to split a word document by its header but not necessarily on every page. The document is generated so that in the header a certain string is created (a reference) the document may be several pages in size. I need to split this document by the header reference. For example...

=== HEADER ===
Ref: 000001
=== END HEADER ===
Some text in the main body of the document...
=== HEADER ===
Ref: 000002
=== END HEADER ===
Some different text in the main body of document....
=== HEADER ===
Ref: 000003
=== END HEADER ===
This one is multipage, blah....
=== HEADER ===
Ref: 000003
=== END HEADER ===
And this is the second page...


The above example is a bit crude but effectively I should end up with...
000001.doc [1 page]
000002.doc [1 page]
000003.doc [2 pages]

The article i was using before obviously does not search within the document header, but even when i search inside headers i find it difficult to figure out which page this header refers to etc.

Hoping someone someone has the smarts to help, thanks.

lucas
02-03-2010, 08:46 AM
Maybe this will help. Post #2:

http://www.vbaexpress.com/forum/showthread.php?t=11113&highlight=copy+table+row

fumei
02-03-2010, 10:31 AM
The most important question is: are there different headers for FirstPage, OddEven in any given Section?

If they are NOT, then you can simply extract the Section.

" i find it difficult to figure out which page this header refers to etc."

The reason for this difficulty is that Headers do not refer to pages.