Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-20-2011, 10:09 AM
webharvest webharvest is offline Update bookmarks and variables in document Windows Vista Update bookmarks and variables in document Office 2007
Novice
Update bookmarks and variables in document
 
Join Date: Jun 2011
Posts: 6
webharvest is on a distinguished road
Default Update bookmarks and variables in document

I have a user form that I use to put information into bookmarks and docvariables. When I insert the text from the userform into a bookmark I do the following to reestablish the bookmark.



Code:
pStr = Replace(.PropName.Value, Chr(10), Chr(10) + Chr(9))
Set oRng = ActiveDocument.Bookmarks("PropName").Range
oRng.Text = pStr
ActiveDocument.Bookmarks.Add "PropName", oRng
The above code works great but here is my problem. When someone creates a new document from my template the user form comes up and everything is entered but I give the user the rights to update the word document after the form populates everything. So what I am seeing happen is the person goes to change the Proposal Name (PropName bookmark in the document) and since there are no spaces before or after the bookmark text they end up deleting the bookmark when they type the new name in. I believe this is because when you select the whole text it automatically selects the bookmark tags so when you start typing the new text the book mark is deleted.

1) So the best solution would be if I can somehow protect a bookmark from being deleted when inside the document but unlock it when I run the vba code above.
2) An alternative solution would be to add several spaces at the end of the text inside the bookmark when the above vba code creates the bookmark. This would make it harder to select everything and delete the bookmark.

I would like to make it impossible but I will take what I can get.

Thank you ahead of time.
Reply With Quote
 

Tags
bookmarks, protect bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of Contents does not update, when document is opened on other computer jaybo Word 1 01-25-2011 04:56 PM
Update Document Template when Saving the Document File bjbercaw Word 3 11-16-2010 02:03 PM
Bookmarks for a PDF? Ownaholic Word 0 10-30-2010 12:27 AM
Using bookmarks in a protected document Bill Stemp Word 0 10-16-2010 06:47 AM
Envelopes with Document Variables mailtobln Word 0 02-11-2009 10:48 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:52 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