How to get list of all bookmark-elements from a Word document to an array in order by location: VBA / Word

本秂侑毒 提交于 2019-12-05 21:52:21

Oki, so i figured it out,

Here's how its done if someone else is interested in fetching all of the bookmarks with respect to its location on document.

Dim objDoc As Document
Set objDoc = ActiveDocument

For i = 1 To objDoc.Bookmarks.Count
Debug.Print objDoc.Range.Bookmarks(i) 'here you can change the code to push the bookmarks in an array
Next i

In case anyone still wants to know; you can access different parts of a MS Word document, like this:

ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Bookmarks.Count
ActiveDocument.StoryRanges(wdMainTextStory).Bookmarks.Count
ActiveDocument.StoryRanges(wdPrimaryFooterStory).Bookmarks.Count
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!