TKovacs
Fri May 18 15:55:01 CDT 2007
You are right. I overlooked that. Thank you!
"Jay Freedman" wrote:
> You completely ignored what Jean-Guy told you. DO NOT set the
> Bookmarks("PreferredName").Range.Text. That usage is why you're being
> forced to unprotect/reprotect and why your field is being deleted.
>
> Instead,
>
> >> ActiveDocument.FormFields("PreferredName").Result = ""
>
> will clear the field and leave it ready to accept new text -- and you
> DO NOT need to unprotect the document to do this.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ:
http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
>
> On Fri, 18 May 2007 13:05:01 -0700, TKovacs
> <TKovacs@discussions.microsoft.com> wrote:
>
> >When I attempt to set it = "" I get an error that reads "You are not allowed
> >to edit this selection because it is protected". So I tried this:
> >
> >ActiveDocument.Unprotect
> >Word.ActiveDocument.Bookmarks("PreferredName").Range.Text = ""
> >ActiveDocument.Protect wdAllowOnlyFormFields, True 'Re-protect
> >
> >The result: That form field is gone...... Grrr
> >
> >
> >
> >
> >
> >
> >"Jean-Guy Marcil" wrote:
> >
> >> TKovacs was telling us:
> >> TKovacs nous racontait que :
> >>
> >> > That got me part way. Thanks. The other part is how can I erase
> >> > what is in a field without erasing the field? I tried setting the
> >> > text to 5 non-breaking spaces, but it still disappeared.
> >> >
> >> > Word.ActiveDocument.Bookmarks("PreferredName").Range.Text =
> >> > ChrW(8194) & ChrW(8194) & ChrW(8194) & ChrW(8194) & ChrW(8194)
> >> >
> >> > Do you have a solution to that? Thanks!
> >>
> >> If you are going to work with formfields, use the formfield object, not the
> >> Bookmark one.
> >>
> >> Your code above essentially replaces the range of the formfield with spaces,
> >> therefore deleting it, but you would have to unprotect the document first..
> >>
> >> In your original post, you wrote that you wanted to detect if a formfield
> >> was made of those 5 default spaces, and if so, delete the content.
> >> Now you are asking about how to insert those 5 spaces....
> >> I am a bit confused.
> >>
> >> To delete a formfield content, just use:
> >>
> >> ActiveDocument.FormFields("Text1").Result = ""
> >>
> >> This will automatically insert the 5 spaces you are writing about.
> >>
> >> Are you sure you are working with formfields and a protected document?
> >>
> >> --
> >>
> >> Salut!
> >> _______________________________________
> >> Jean-Guy Marcil - Word MVP
> >> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> >> Word MVP site:
http://www.word.mvps.org
> >>
> >>
> >>
>