Make the header and footer visible in a word document (2003 .doc) through Office Interop Library
I am currently opening a word 2003 .doc file and using 开发者_开发百科the Office Interop to get information out of it. For some reason the program will fail reading information from the header if it is not visible.
Has anybody checked to see if the header was visible through this before? How would I go about doing it?
From other posts I've found some documentation for Word 2007 (not the version I'm using) but I can't find 2003 documentation. I couldn't find any helpful information in the 2007 documentation but from what I found it may have something to do with the header/footers and a style (no idea how to apply a "style" to them or even check the style.
You can read info from a header if it's not visible, but often, if a header or footer isn't visible, it's because it doesn't exist. Word has 3 headers/footers, Normal, First page, and even (or is it odd) pages. But they don't actually have to exist. And Note that each SECTION can have its own version of all three of those objects, OR any of those objects in the section can "Link to previous", in which case, the section itself doesn't have the object, but rather a pointer to the same object in the previous section. Confusing? Oh yeah!
Check that with the EXISTS property on the headerfooter object. If it's false, don't bother with the header/footer cause it's not there.
Beware, though, that in some cases, simply checking the header footer will actually +create+ it, if it wasn't there before. and creating a header footer tends to drop a paragraph into it, which, depending on how the document is formatting, might affect the layout of the document slightly (adding a little extra space). If the doc was tightly formatted to the page, you could end up creating a second page inadvertantly.
Just something to be aware of.
精彩评论