简体   繁体   English

按位置在vba中对单词书签进行排序

[英]Sorting word bookmarks by location in vba

I am trying to cycle through the bookmarks in a word document by their location. 我试图通过他们的位置在word文档中循环显示书签。

yes I have seen this: How to get list of all bookmark-elements from a Word document to an array in order by location: VBA / Word 是的我已经看到了这个: 如何按位置按顺序获取Word文档中所有书签元素的列表:VBA / Word

no it didn't work. 不,它不起作用。 and for the life of me I am not sure why this doesn't since it is lifted from a MS support page. 而对于我的生活,我不知道为什么这不会,因为它是从MS支持页面解除的。

Sub cycleBookmarks()
 ActiveDocument.Bookmarks.DefaultSorting = wdSortByLocation
 Dim bkm As Bookmark
  For Each bkm In ActiveDocument.Bookmarks
  Next bkm
End Sub

Anybody know how to properly cycle through bookmarks by document location? 有人知道如何通过文档位置正确循环书签吗? I don't care about headers and footers (though a complete answer would be nice) 我不关心页眉和页脚(虽然完整的答案会很好)

According to this MSDN site DefaultSorting property : 根据这个MSDN站点的 DefaultSorting property

Returns or sets the sorting option for bookmark names displayed in the Bookmark dialog box (Insert menu). 返回或设置“书签”对话框(“插入”菜单)中显示的书签名称的排序选项。 Read/write WdBookmarkSortBy. 读/写WdBookmarkSortBy。

Therefore you need to use @Mana solution from the link you provided in your question. 因此,您需要使用您在问题中提供的链接中的@Mana解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM