![]() |
#1
|
|||
|
|||
![]()
I have two macro routines, ListBookmarks1 and ListBookmarks2, that are intended to capture bookmarks in a Word document.
ListBookmarks1 uses a for loop to get the bookmarks, while ListBookmarks2 writes the bookmarks to an array. The difference is that ListBookmarks1 ignores the bookmarks in headers, footers, shapes and other stories, while ListBookmarks2 captures all bookmarks because of the array. Apparently, bookmarks in headers, footers, and shapes aren't part of the Document.Bookmark collection. What’s odd is that ActiveDocument.Bookmarks.count produces a count of all bookmarks, including those outside the bookmark collection. ListBookmarks1 writes the bookmarks it does find to a new document, and ListBookmarks2 writes them to either a new document or a message box (depending on what code is commented out). Both include each bookmark’s location (page and line number). The problem I’m having is that I am not able to get the array to display properly in either the new Word doc or the message box. The attached test doc contains the macros and eight bookmarks – 5 in the body, 1 in the header, 1 in a shape, and 1 in a table. I have switched on the “show bookmarks” and written their names followed by “BOOKMARK” in bold italics to make them easier to find. The bookmarks are: Browser DOS Header IPadd PhysAdd Status Tablebkmk Txtbox ListBookmarks1 correctly shows 8 bookmarks with their locations (it ignores “Browser“ and “Txtbox”). ListBookmarks2 shows the first 7 but the locations are mismatched by one row. However, all bookmarks and locations are captured in the array; it is evidently the display that’s not working properly in both the document and msgbox displays. Can someone help with the displays? |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Dom37 | Word VBA | 2 | 10-31-2011 03:28 AM |
Bookmarks for a PDF? | Ownaholic | Word | 0 | 10-30-2010 12:27 AM |
![]() |
Jaffa | Excel | 1 | 10-23-2010 02:39 PM |
Macro to remove duplicates in Refrences list | HowardC | Word VBA | 0 | 05-20-2010 09:57 AM |
Show bookmarks | dempen | Word | 2 | 01-14-2010 11:47 PM |