how to update form that is protected

D

Daniel M

I have a form that is running in protected mode so that the users cannot
change the form only fill it out. This is done with the lock icon on the
form toolbar. I have a table that runs a macro whenever i leave one cell i
copy the contents to another cell but this refuses to run when locked. If i
unlock the form it works fine. I have tried to even change the field to a
editable field but it still tells me i cannot edit this in a protected
document. Can anyone tell me how i can do this or if there is a better way
to protect the form? Here is the code i am running in the macro...

Dim crange As Range
With ActiveDocument.Tables(1)
Set crange = .Cell(13, 2).Range
crange.End = crange.End - 1
.Cell(13, 3).Range.Text = "*" & crange.Text & "*"
End With


Thanks.
dm.
 
D

Doug Robbins - Word MVP

Dim crange As Range
With ActiveDocument
.Unprotect
With .Tables(1)
Set crange = .Cell(13, 2).Range
crange.End = crange.End - 1
.Cell(13, 3).Range.Text = "*" & crange.Text & "*"
End With
.Protect wdAllowOnlyFormFields
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Daniel M

Well good try but now i have another problem. Whenever you have a form and
you unprotect it, all the data in the form fields is cleared out. so i fill
out half of the form, run the macro and all i am left with is the copied
data. Any other ideas?

dm.
 
D

Doug Robbins - Word MVP

Use

Dim crange As Range
With ActiveDocument
.Unprotect
With .Tables(1)
Set crange = .Cell(13, 2).Range
crange.End = crange.End - 1
.Cell(13, 3).Range.Text = "*" & crange.Text & "*"
End With
.Protect wdAllowOnlyFormFields, NoReset
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Daniel M

That worked! Thanks for the help!!

dm.

Doug Robbins - Word MVP said:
Use

Dim crange As Range
With ActiveDocument
.Unprotect
With .Tables(1)
Set crange = .Cell(13, 2).Range
crange.End = crange.End - 1
.Cell(13, 3).Range.Text = "*" & crange.Text & "*"
End With
.Protect wdAllowOnlyFormFields, NoReset
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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