Word 2000 - Date Fields

  • Thread starter Sandra Jackson via OfficeKB.com
  • Start date
S

Sandra Jackson via OfficeKB.com

Is it possible to write a macro that would lock all date fields when
closing the document?

Sandra
 
G

Greg Maxey

Sandra,

Try:
Sub LockDateFields()
Dim pRange As Word.Range
Dim oFld As Field
For Each pRange In ActiveDocument.StoryRanges
Do
For Each oFld In pRange.Fields
If oFld.Type = wdFieldDate Then
oFld.Locked = True
End If
Next
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
 
S

Sandra Jackson via OfficeKB.com

I tried the macro at work and it was fine, except When I've created a
document and inserted the form fields I have to:

1) Run the macro
2) Save the document
3) Close
4) Reopen

This will keep the fields locked when I reopen

If I:

1) Save the document
2) Run the macro
3) Close
4) Reopen

The fields are not locked when I reopen.

As there will be other people using this macro who might save the right way
round is there any way round this?

Regards
Sandr
 

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