Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-11-2014, 04:32 PM
macropod's Avatar
macropod macropod is offline Cross Referencing Bookmarks populated from a userform Word 2010 Windows 7 32bit Cross Referencing Bookmarks populated from a userform Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

When you output text to a collapsed bookmarked range, the text gets inserted after it. The 'correct' way to update a bookmark is to use code like:
Code:
Sub UpdateBookmark(StrBkMk As String, StrTxt As String)
Dim BkMkRng As Range
With ActiveDocument
  If .Bookmarks.Exists(StrBkMk) Then
    Set BkMkRng = .Bookmarks(StrBkMk).Range
    BkMkRng.Text = StrTxt
    .Bookmarks.Add StrBkMk, BkMkRng
  End If
  .Fields.Update
End With
Set BkMkRng = Nothing
End Sub
and call the process with something like:
Call UpdateBookmark("bookmark_name", "bookmark_text")
If needed, you can call the same sub repeatedly, with different bookmark names and/or bookmark text, such as when you have multiple bookmarks to update or when you need to change the contents of a particular bookmark.
The .Fields.Update method updates the cross-references.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
bookmark, cross reference, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Bookmarks from a Userform alshcover Word VBA 12 01-12-2015 06:53 PM
Cross-referencing Bookmarks and Formatting kd12 Word 6 06-09-2014 09:20 PM
Cross Referencing Bookmarks populated from a userform Word 2010 issues with cross-referencing khaines Word 7 03-15-2012 03:25 AM
Cross-referencing figure in Word 2003 - Problem ultimateguy Word 0 07-30-2009 12:37 PM
Cross referencing maltesedog Word 0 02-13-2009 07:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:29 AM.


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