M
mansky99
Hi,
I have a User who, by mistake, used a Date Field in Word documents to place
a date in a document. The intention was to have that date to be fixed and
unchanged
the next time the document was opened. The dates are journal entries (ie. a
date and some text)
and hence it's important that the dates remain unchanged upon subsequent use
of the file.
I have a script to go thru all the Word docs on the machine where the
problem resides.
However, it appears that I have to first use the method Documents.Open
before I can use the method Documents.Fields.Count to see if there are any
fields in a given document.
Here's a code snippet of the script to toggle the Locked property of all
fields in a given document
from False to True :
For i = 1 To NF
Fullname = Pathnames(i) & Filenames(i)
Documents.Open Filename:=Fullname
If (Documents(Fullname).Fields.Count > 0) Then
For Each ADF In Documents(Fullname).Fields
If (ADF.Locked = False) Then
ADF.Locked = True
Documents.Close SaveChanges:=wdSaveChanges
Else
Documents.Close SaveChanges:=wdDoNotSaveChanges
End If
Next ADF
End If
Loop i
where the Variant arrays Pathnames and Filenames contain the paths and
filenames of all the
Word documents on the affected machine.
The problem is that as soon as Documents.Open is called, the date fields (as
per design) are updated, thereby nullifying my script.
I'd like to change the Locked property value of any fields in a given
document from False to True
(to thereby prevent subsequent updating of date fields), but I can't seem to
get around using
Documents.Open. If I leave out the call to Documents.Open, I get a 'Bad
filename' error from the
Documents(Fullname).Fields.Count statement.
Any ideas on how to toggle the Locked property, or other ideas would be
greatly appreciated!
Ed
I have a User who, by mistake, used a Date Field in Word documents to place
a date in a document. The intention was to have that date to be fixed and
unchanged
the next time the document was opened. The dates are journal entries (ie. a
date and some text)
and hence it's important that the dates remain unchanged upon subsequent use
of the file.
I have a script to go thru all the Word docs on the machine where the
problem resides.
However, it appears that I have to first use the method Documents.Open
before I can use the method Documents.Fields.Count to see if there are any
fields in a given document.
Here's a code snippet of the script to toggle the Locked property of all
fields in a given document
from False to True :
For i = 1 To NF
Fullname = Pathnames(i) & Filenames(i)
Documents.Open Filename:=Fullname
If (Documents(Fullname).Fields.Count > 0) Then
For Each ADF In Documents(Fullname).Fields
If (ADF.Locked = False) Then
ADF.Locked = True
Documents.Close SaveChanges:=wdSaveChanges
Else
Documents.Close SaveChanges:=wdDoNotSaveChanges
End If
Next ADF
End If
Loop i
where the Variant arrays Pathnames and Filenames contain the paths and
filenames of all the
Word documents on the affected machine.
The problem is that as soon as Documents.Open is called, the date fields (as
per design) are updated, thereby nullifying my script.
I'd like to change the Locked property value of any fields in a given
document from False to True
(to thereby prevent subsequent updating of date fields), but I can't seem to
get around using
Documents.Open. If I leave out the call to Documents.Open, I get a 'Bad
filename' error from the
Documents(Fullname).Fields.Count statement.
Any ideas on how to toggle the Locked property, or other ideas would be
greatly appreciated!
Ed