can't write to textfields

W

william

Hi,

i created a FORM for data entry, and for writing data to textfields in a document. the document is protected so that users can't delete the textfields. but, then i can't write data to the textfields. the error is "...the object refers to a protected area of the doc". do you have any idea/hint? this is the code.

ActiveDocument.FormFields("text3").TextInput.Clear
ActiveDocument.FormFields("text3").Result = txtToCompany

Set rng = ActiveDocument.FormFields("text3").Range

rng.Font.Size = 15
rng.Font.Name = "Arial"
rng.Bold = True

thank you very much.

william.
 
G

Greg

William,

Add code to unprotect and then protect the document:

ActiveDocument.Unprotect
ActiveDocument.FormFields("text3").TextInput.Clear
ActiveDocument.FormFields("text3").Result = txtToCompany
Set rng = ActiveDocument.FormFields("text3").Range
rng.Font.Size = 15
rng.Font.Name = "Arial"
rng.Bold = True
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub
-----Original Message-----
Hi,

i created a FORM for data entry, and for writing data to
textfields in a document. the document is protected so
that users can't delete the textfields. but, then i can't
write data to the textfields. the error is "...the object
refers to a protected area of the doc". do you have any
idea/hint? this is the code.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < William > écrivait :
In this message, < William > wrote:

|| Greg,
||
|| thanks a lot. how can i check if the doc. is protected? -w

???
You said so yourself:
<Quote>
then i can't write data to the textfields. the error is "...the object
refers to a protected area of the doc".
<End quote>

You original reason to write to this group was a message telling you that
your document was protected. Someone gives you the workaround and then you
ask a very cryptic question, to say the least!

Maybe you meant something else... Then you have to elaborate.

By the way, how did you manage to post the same message about 9 times?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
W

William

hi,

the question: how can i check if the doc. is protected? i meant in the VBA code, if the doc. is protected, do something. otherwise, something else.

i had problems to post to the newgroup the first 8 times. i typed in my message, and sent them. but, i got the error. finally, i posted it. but, i didn't know why the first 8 messages also posted to the group. do you have an idea?

thanks,

william.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < William > écrivait :
In this message, < William > wrote:

|| hi,
||
|| the question: how can i check if the doc. is protected? i meant in the
VBA code, if the doc. is
|| protected, do something. otherwise, something else.

Something like:
'_______________________________________
Set Doc = ActiveDocument
If Doc.ProtectionType <> wdNoProtection Then
MsgBox "Removing protection...", vbExclamation
Doc.Unprotect
Else
MsgBox "This document is not protected.", vbExclamation
End If
'_______________________________________

???

|| i had problems to post to the newgroup the first 8 times. i typed in my
message, and sent them.
|| but, i got the error. finally, i posted it. but, i didn't know why the
first 8 messages also
|| posted to the group. do you have an idea?
||

Patience! Depending on the server, location, interface, etc. it can take up
to a couple of hours before your message is posted. I use OE and it never
takes more than a few minutes.
How are you posting?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top