Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2014, 11:29 AM
ptmuldoon ptmuldoon is offline Identify BookMark Location Windows 7 64bit Identify BookMark Location Office 2013
Advanced Beginner
Identify BookMark Location
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 12-13-2014, 02:20 PM
macropod's Avatar
macropod macropod is offline Identify BookMark Location Windows 7 64bit Identify BookMark Location Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
However, in a document subject to editing (as the risk of inadvertent deletion or even just updating the bookmarked content as per the 'UpdateBM' code in your other thread (https://www.msofficeforums.com/word-...out-loops.html) evidences), those start & end points are liable to change with every keystroke. Consequently, retrieving their locations is only valid for that instant.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-13-2014, 11:17 PM
gmayor's Avatar
gmayor gmayor is offline Identify BookMark Location Windows 7 64bit Identify BookMark Location Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #4  
Old 12-14-2014, 09:26 AM
ptmuldoon ptmuldoon is offline Identify BookMark Location Windows 7 64bit Identify BookMark Location Office 2013
Advanced Beginner
Identify BookMark Location
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 12-14-2014, 01:51 PM
macropod's Avatar
macropod macropod is offline Identify BookMark Location Windows 7 64bit Identify BookMark Location Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Identify BookMark Location 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
Identify BookMark Location VBA to copy bookmark to a new location kent Word VBA 5 06-14-2012 02:18 PM
Identify BookMark Location identify non-members from two lists rterrain03 Office 5 12-01-2011 01:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft