阅读word文档的索引(目录)

时间:2023-01-20 06:24:46

I am interested to get the topic headings (say all lines with Heading 1 and Heading 2) from a word document. Using VBA you can parse thru every line in that document and verify the style; however this seems to be a tedious job. I believe that there should be some easy way of doing it. Any pointers

我有兴趣从word文档中获取主题标题(比如标题1和标题2的所有行)。使用VBA,您可以解析该文档中的每一行并验证样式;然而,这似乎是一项繁琐的工作。我相信应该有一些简单的方法。任何指针

2 个解决方案

#1


A pointer --->

指针--->

tempD = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)

tempD = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)

gives you a list of Headings in document.

为您提供文档中的标题列表。

#2


This was answered earlier, I should have searched again before submitting the question

这是早些时候回答的,我应该在提交问题之前再次搜索

Getting the headings from a Word document

从Word文档中获取标题

Just copying it here for everyone's reference

只需将其复制到此处供大家参考

#1


A pointer --->

指针--->

tempD = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)

tempD = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)

gives you a list of Headings in document.

为您提供文档中的标题列表。

#2


This was answered earlier, I should have searched again before submitting the question

这是早些时候回答的,我应该在提交问题之前再次搜索

Getting the headings from a Word document

从Word文档中获取标题

Just copying it here for everyone's reference

只需将其复制到此处供大家参考