How to globally disable "{TIME \@ "MMMM d, yyyy"}"

G

Guest

We produce office documents that have the {TIME \@ "MMMM d, yyyy"} function
in a field. It was used on a template that is now included in many
documents. The problem is that when you later go to access the record or
document, the current date shows up as opposed to when the document was
created or last saved. Is there any way to prevent this feature from
updating to the current date without asking or at all?
Of course, I would like a way to do this without having go and open each
individual file and make a change in each one. I was hoping to be able to
accomplish this globally.

Thanks in advance for your help.
Keyser318
 
G

Guest

Maybe you could add some code to the AutoOpen macro, checking for the
specified field, and if it exists, change it to regular text. I imagine that
AutoOpen code runs before document fields are updated.

Andrew
 
G

Guest

How do I find and open the AutoOpen macro. I looked for it, but couldn't
find it in the list of word commands. Is there somewhere else that it could
be? I will try and see if that will fix the problem, but I am not sure where
to look.

Thanks again.

Keyser
 
G

Greg Maxey

Keyser,

First you have to decided if you want the Time (which inserts the PC
clock time formatted in your case as a date) to a CREATEDATE field
SAVEDATE Field.

You could then process all of your files based on that template as a
batch to change your current TIME field to one of two field mentioned
above. You could also use an AutoOpen macro in the template that would
process the files individually as you open them. Something like this
may do for a CREATEDATE option:
Sub AutoOpen()
Dim oFld As Word.Field
For Each oFld In ActiveDocument.Fields
If oFld.Code.Text = " Time \@ MMMM d, yyyy " Then
oFld.Code.Text = " CREATEDATE \@ MMMM d, yyyy "
End If
Next
End Sub
 
G

Guest

These files are stored on a server which local machines access to retrieve
the files. I have four questions:

1.) Is there anyway to alter the code for {TIME \@ "MMMM d, yyyy"} so that
it doesn't go look at the local time either when it opens or ever?

2.) How do I access and edit an auto open macro? I assume that this is
referring to a macro that you create, but how do I classify it as an auto
open one?

3.) If I make these changes to the auto open one on the server, will it
apply to all users who access these files on a local machine? Or will I have
to put the macro on all machines?

4.) How would I go about processing a batch of files that are contained in
many directories and subdirectories and have files other than word dispursed
among them? The other problem is that many of them are based on the same
template, but some older ones are based on others.

Thanks so much to all of you for your help.

Keyser318
 
G

Greg Maxey

1. Yes. Change the code to in the documents to { CREATEDATE \@ "MMMM
d, yyyy" }

2. Open the template file. Press ALT+F11 to open the VB Editor.
Paste in the code I provided earlier.

3. I don't know for sure about this. If the folks on the local
machines aren't connected to the server then my guess would be that you
will have to install the template on both the server and the local
machine.

4. Write a macro that processes all word documents in the
folder/sub-folder your designate to change your current { Time } field
to a { CREATEDATE } field. It doesnt' matter what template they were
created from.
 
G

Greg Maxey

For question 4 you might consider using:

Sub BatchProcessFiles()
Const pBatchDir = "C:\Batch Process"
Dim objFSO As Scripting.FileSystemObject
Dim objBatchFolder As Scripting.Folder
Dim objFile As Scripting.File
Dim oFld As Word.Field
Dim curCursor As Long
Dim strExtName As String
'Specify the file type
strExtName = "*.DOC"
Set objFSO = New Scripting.FileSystemObject
Set objBatchFolder = objFSO.GetFolder(pBatchDir)
'Minimize screen flicker
curCursor = System.Cursor
System.Cursor = wdCursorWait
Application.ScreenUpdating = False

For Each objFile In objBatchFolder.Files
If UCase(objFile.Name) Like strExtName Then
Application.Documents.Open objFile.Path
With ActiveDocument
For Each oFld In .Fields
If UCase(oFld.Code.Text) = " TIME \@ ""MMMM D, YYYY"" " Then
oFld.Code.Text = " CREATEDATE \@ ""MMMM d, yyyy"" "
End If
Next oFld
.Close SaveChanges:=wdSaveChanges
End With
End If
Next objFile
Set objFile = Nothing
'Call recursive function
ProcessSubFolders objBatchFolder.SubFolders, strExtName
Set objFSO = Nothing
Set objBatchFolder = Nothing
'Restore visuals
Application.ScreenUpdating = True
System.Cursor = curCursor
End Sub
Function ProcessSubFolders(ByRef objBatchFolders As Scripting.Folders,
_
ByRef strFileExt As String)
Dim oSubFolder As Scripting.Folder
Dim oSubFolderFile As Scripting.File
Dim oFld As Word.Field
For Each oSubFolder In objBatchFolders
For Each oSubFolderFile In oSubFolder.Files
If UCase(oSubFolderFile.Name) Like strFileExt Then
Application.Documents.Open oSubFolderFile.Path
With ActiveDocument
For Each oFld In .Fields
If UCase(oFld.Code.Text) = " TIME \@ ""MMMM D, YYYY"" " Then
oFld.Code.Text = " CREATEDATE \@ ""MMMM d, yyyy"" "
End If
Next oFld
.Close SaveChanges:=wdSaveChanges
End With
End If
Next oSubFolderFile
'Run function for each sub-folder
If oSubFolder.SubFolders.Count > 0 Then
ProcessSubFolders oSubFolder.SubFolders, strFileExt
End If
Next oSubFolder
Set oSubFolderFile = Nothing
Set oSubFolder = Nothing
End Function
 
G

Guest

If I do that, won't it make the date the same for all of the files and equal
to the date on which I run the macros because you have to insert text and
then resave the new fxn?

If I use the auto open macro, that will only work for documents created from
now on forward right? Or does it keep the date correct before it has a
chance to change it?

Thanks again for all of your help.

Keyser318
 

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