通过 Office Interop Library 使页眉和页脚在 Word 文档 (2003 .doc) 中可见

发布于 2024-09-18 04:05:57 字数 260 浏览 4 评论 0原文

我当前正在打开一个 word 2003 .doc 文件并使用 Office Interop 从中获取信息。由于某种原因,如果标题不可见,程序将无法从标题中读取信息。

有人检查过标题是否通过此可见吗?我该怎么做呢?

从其他帖子中,我找到了一些 Word 2007 的文档(不是我正在使用的版本),但我找不到 2003 文档。我在 2007 年文档中找不到任何有用的信息,但从我发现的内容来看,它可能与页眉/页脚和样式有关(不知道如何对它们应用“样式”,甚至不知道如何检查样式。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百思不得你姐 2024-09-25 04:05:57

如果页眉不可见,您可以从页眉中读取信息,但通常,如果页眉或页脚不可见,则是因为它不存在。 Word 有 3 个页眉/页脚:普通页、首页和偶数(或奇数)页。但它们实际上不必存在。请注意,每个 SECTION 都可以拥有所有这三个对象的自己的版本,或者该部分中的任何对象都可以“链接到上一个”,在这种情况下,该部分本身没有该对象,而是一个指针到上一节中的同一对象。令人困惑?噢耶!

使用 headerfooter 对象上的 EXISTS 属性进行检查。如果它是假的,请不要理会页眉/页脚,因为它不在那里。

但请注意,在某些情况下,只需检查页眉页脚实际上就会创建它(如果之前不存在的话)。创建页眉页脚往往会在其中放入一个段落,这取决于文档的格式设置,可能会稍微影响文档的布局(添加一些额外的空间)。如果文档的格式与页面紧密相关,您最终可能会无意中创建第二个页面。

只是需要注意一些事情。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文