![]() |
|
#1
|
|||
|
|||
![]()
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 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. |
#2
|
||||
|
||||
![]()
Hi webharvest,
So why are the users allowed to edit things like the Proposal Name other than through the userform? Bookmarks are fragile. So, instead of using bookmarks, I'd suggest having your code maintain/update custom document properties with the data and use DOCPROPERTY fields where required to replicate the data.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Well my initial thought was I would just use the userform to make the creation of the document easier and then let the person edit the document as normal after the initial creation. I initially thought this way because the people doing this work are not very computer savvy and I figured I would get less resistance.
When you say docproperties do you mean document variables? If so I am using them in some places of the userform. Okay so lets say I do only allow the person to change these variables via the userform; I have a couple questions 1) Right now I only call up the userform when a new document is created from the template. What is a clean way to have the userform pop back up when the user wants to change something? I thought about a macro button but we have to print or make pdfs to send out to people and I don't want the button to show up in the final document. 2) What is the right way to lock down all the docvariables and/or book marks but still let the user modify the rest of the document? There is a lot of text that needs to be document specific so I have to let the user change some things. Thanks |
#4
|
||||
|
||||
![]()
Hi webharvest,
The best approach might be to configure the document as a Word form with a combination of protected and unprotected Sections, delineated by continuous or next-page Section breaks. In the protected Section(s), you would have formfields into which the users could input data (eg the Proposal Name) only. Anything else in a protected Section would be inaccessible. If the same data that is to be input into a formfield appears in multiple places, you could set the formfield properties to 'calculate on exit' and have cross-references at the other locations, all pointing to the formfields' internal bookmark names. In the unprotected Section(s), you'd have any content that the users are allowed to edit. See attached document.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
That sounds like a good approach. But I do have a couple of questions
1) Is there a good way to call up the userform after the initial creation of the document? Right now in your example doc if the person clicks on the protected area they would have no way of knowing they can only change that field by opening the userform. What would be ideal is when the person clicks on the protected text the userform automatically opens. Another alternative is when the user clicks on the protected text a note pops up telling the user how to open the userform. 2) The problem is I don't want to put a macro button on the page because won't that show up when the document is printed? 3) If the section is protected and info can only be put in via the form do I need to turn protection off and then turn it back in VBA when the form goes to enter the update? What is the code for that? Thanks |
#6
|
||||
|
||||
![]()
Hi webharvest,
With the approach I suggested, you wouldn't need a userform. When you open such a document, it will position the cursor at either: a) the first formfield if there is one in the first (protected) Section; or b) at the start of the document otherwise. Also, no macros are required for this approach, which obviates any macro security issues and the risk that users will choose to disable the macro that drives your userform upon opening. I think your third question is based on a misunderstanding. As you'll see from the document I posted, the cross-reference updates immediately you tab out of the first formfield. No vba is required. If you have more than one formfield in the protected section, tabbing out of one automatically takes you to the next one.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
bookmarks, protect bookmarks |
|
![]() |
||||
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 |