#1
|
|||
|
|||
Identify BookMark Location
I'm still learning more on how BookMarks are handled in Word, and I'm wondering if this possible before I get to involved. Is it possible to learn both the BookMark Name and Location within a document? I'd like to have a full listing of all BookMarks where I can create a 'Reset' macro that will add/replace all BooksMarks should the user inadvertently delete them. I've learned how to search/loop a document and get all the Names, but not sure how you can determine the location of each BookMark. |
#2
|
||||
|
||||
Bookmarks span ranges, which means you can retrieve their start & end points. For example:
Code:
Sub Demo() With ActiveDocument.Bookmarks("Bookmarkname") MsgBox .Range.Start & vbTab & .Range.End End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
A problem with using bookmarks is that you cannot readily see them in a document (even if they are displayed), and they are easily overwritten. You could use http://www.gmayor.com/BookmarkandVariableEditor.htm as an aid to list them.
Other types of place marker are more robust. For example you could use content controls, which can be protected from accidental deletion, or you could use document variables. Whichever you use, create a template rather than a document as the new documents created from it will always have the bookmarks/variables/content controls that you put in it, even if the user screws up the document.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#4
|
|||
|
|||
Thanks Mayor and Macropod.
You just opened up a whole new area to explore and learn. I'm going to start reading up on Content Controls and using Variables. On a side note. Do you know of any good Word VBA books out there? There's plenty of Excel vba books, but most of my word learning is from google and searching Last edited by ptmuldoon; 12-14-2014 at 10:58 AM. |
#5
|
||||
|
||||
Most of my Word knowledge & programming skills are self taught, developed whilst helping other users solve their Word productivity issues. Consequently, I can't point to a textbook I've found useful for learning this stuff.
A book you might find useful is The Secret Life of Word: A Professional Writer's Guide to Microsoft Word Automation, by R Delwood, published by XML Press in 2011(http://xmlpress.net/publications/word-secrets/). I contributed content for and did much of the technical review of this book. This isn't a programming book as such (though it does have some programming in it) and doesn't profess to teach you how to program. Rather, it shows how to combine Word's various tools to achieve whatever the desired result might be. Another that I contributed to (and has much more programming in it) is Word Hacks, by A Savikas, published by O'Reilly Media in 2005 (http://shop.oreilly.com/product/9780596004934.do). I contributed content for this book also. Although it pre-dates Office 2007, much of the content is still relevant.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Move shape to bookmark location | Byron Polk | Word VBA | 4 | 08-07-2014 03:21 AM |
Bookmark vertical location seems slightly off for some paragraphs | MaxInCO | Word VBA | 4 | 02-21-2014 03:12 PM |
Outlook 2007 win7x32 Archive location/backup location question | michael.monaco | Outlook | 0 | 11-19-2012 02:07 PM |
VBA to copy bookmark to a new location | kent | Word VBA | 5 | 06-14-2012 02:18 PM |
identify non-members from two lists | rterrain03 | Office | 5 | 12-01-2011 01:41 PM |