Printing Several Documents folder without opening separately

G

Gerry Ireland

Word 2003- Professional

I want to be able to print sevaral documents that have been saved into one
folder without opening each one separately and I want the date on the printed
document to be dated the actual date of the document and not the date of
printing
 
G

Graham Mayor

Word has to be opened in order to print the document. If you open a document
with a date field then that field will update to the current date.

The reason is that a date field which shows the system date. What you need
to do is change those date fields for createdate fields - ALT+F9 change
{DATE \@ "d MMM yyyy"}or {TIME \@ "d MMM yyyy"} to {CREATEDATE \@ "d MMM
yyyy"} then F9 and ALT+F9 - and change the date in your letterhead template
so that future letters based on it show the correct dates. The switches \@
"d MMM yyyy" may be different at your location.

It is possible to change the Date fields to CreateDate fields of all the
documents in a folder and print the resulting files using a macro, but you
will have to have Word open to run the macro.

In the following, change the switch in the line
sSwitch = "\@ " & Chr(34) & "d MMMM yyyy" & Chr(34)
from d MMMM yyyy to whatever you switch you require for those date fields
that do not already have a switch (A createdate field without a switch will
not have the same format as a date field without a switch). Those fields
that have switches already will retain those switches.

Remove the apostrophe from the begiining of the line
'.Printout
if you wish to print all the documents from the folder using the macro,
though you might want to test it on a few documents first.


Sub BatchChangeDateField()
Dim iFld As Integer
Dim strFileName As String
Dim strPath As String
Dim oDoc As Document
Dim sSwitch As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
sSwitch = "\@ " & Chr(34) & "d MMMM yyyy" & Chr(34)
With fDialog
.Title = "Select Folder containing the documents to be modifed and click
OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFileName = Dir$(strPath & "*.doc")
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
With oDoc
For iFld = .Fields.Count To 1 Step -1
With .Fields(iFld)
If .Type = wdFieldDate Then
If InStr(1, .Code.Text, "@") Then
.Code.Text = Replace(.Code.Text, "DATE",
"CREATEDATE")
.Code.Text = Replace(.Code.Text, "Date",
"CREATEDATE")
Else
.Code.Text = Replace(.Code.Text, _
.Code.Text, "CREATEDATE " & sSwitch)
End If
.Update
.Select
End If
End With
Next iFld
'.PrintOut
.Close SaveChanges:=wdSaveChanges
End With
Set oDoc = Nothing
strFileName = Dir$()
Wend
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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