Document Date Change

G

Guest

My office is using Office 2000 (Word) on XP Pro. I have created many, many
form files/documents that "merge" with Excel via DDE to a finished/new
document that is saved to various other folders under a new file name.

The form files and excel database are located on our server for every user
to access. I originally inserted a date field (via the insert menu) into
each new form file I created. However, that causes a problem at the saving
end of the newly created document. We need the document to maintain its date
at creation and not have the date updated automatically upon reopening the
file a month later.

I removed the inserted date field from each form file manually (one at a
time) and now the process is that each user opening the form file has to type
in the correct month, day, and periodically year. That would be reasonable
except that the form files are "read only" for everyone but the
administrator. So if you open the same file several times in the same day,
you have to retype the correct date each time you open it. Frustrating for
those that are under the "read only" choice.

Is there a way to either globally change the date on all of the form files
without causing the DDE link to drop with the database? It would be great if
there were an auto date update that once the "new" document was created and
saved would not auto update with each new opening of that "new" document that
was saved.

Can anyone point me in the direction to deal with this problem. We have
hundreds of form files. I do not want to manually change the month on each
file individually with each new month of the year.

Thank you,
 
J

Jezebel

Change the DATE fields to CREATEDATE fields. It's going to be a nuisance for
the documents already created, but easy to fix for the future.

How did you come to create "many, many" documents without testing that your
system worked?
 
G

Guest

I was just plucked and assigned with a very, very short time frame -
tomorrow!. This is not my area of interest or expertise, just the busiest
person in the office and expected to "add" to my responsibilities.

Not complaining as I have managed to learn all sorts of new things. But,
not having time to actually research, understand, play, and test things makes
the job a bit more challenging!

Thank you for your help. I will give your suggestion a try.

John
 
G

Graham Mayor

Try the following macro on *copies* of your documents in a dedicated folder
for the purpose.
It opens each document, changes the Date fields to Createdate fields and
updates that revised field.
If the field is indeed a Date field and not a linked field, this should do
the job.

Sub FixAllDates()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer
Dim i As Long

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
ActiveWindow.View.ShowFieldCodes = True
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldDate Then
.Code.Text = replace(.Code.Text, "DATE", "CREATEDATE")
.Update
End If
End With
Next iFld
ActiveWindow.View.ShowFieldCodes = False
MyDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub
 
G

Guest

Thank you. I will give it a try.

--
John R.


Graham Mayor said:
Try the following macro on *copies* of your documents in a dedicated folder
for the purpose.
It opens each document, changes the Date fields to Createdate fields and
updates that revised field.
If the field is indeed a Date field and not a linked field, this should do
the job.

Sub FixAllDates()
Dim myFile As String
Dim PathToUse As String
Dim MyDoc As Document
Dim iFld As Integer
Dim i As Long

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
Set MyDoc = Documents.Open(PathToUse & myFile)
ActiveWindow.View.ShowFieldCodes = True
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldDate Then
.Code.Text = replace(.Code.Text, "DATE", "CREATEDATE")
.Update
End If
End With
Next iFld
ActiveWindow.View.ShowFieldCodes = False
MyDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub
 

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