I want to see the file's name when I print a document

J

johniemi

My problem is this; I have copied several (250+) short texts from a fre
corpus, each to it's own word-file. The texts are swedish newspape
colums and I have named the files by date.

Now I need to print all these out but I also need to know th
chronological order of the print outs. So to recap; The documen
filenames are NAMED by the date, but the docs itself contain no dat
marking.

So I have two options: I go thru all the 250+ docs and copy the dat
from the FILENAME and type the dates in the DOCUMENT by hand or I chec
a check-box in Word so it shows the current file name on the currentl
printed sheet (just like in Windows notepad)

But where is such a check-box? :) Like I said, notepad does this b
default, so I'm sure Word has this option also.

Thanks!

-Joh
 
E

Evi

You can add the FileName using Insert, Autotext, FileName. This doesn't add
the word 'FileName', it adds a field which contains the file name of the
document. You can also use Insert to add the Date and Time. Tick the box
which says Update Automatically and choose a format that shows the minutes
and seconds so that you can put the documents in exact chronological order.

If you want to use VBA to add the FileName and Date fields to all your
documents, move your documents into a folder on your C drive. Call the
folder Test

Option Base 1

Sub CycleThoughDocs()

'Evi Woolston

Dim MyPath As String

Dim MyDoc() As String

Dim Counter As Integer

Dim MyName

Dim a As Integer

Dim DocCount As Integer

DocCount = 3

'the number of files in your folder

ReDim MyDoc(DocCount) As String

MyPath = "C:\Test\"

MyName = Dir(MyPath)

MyDoc(1) = MyName

'file name of first doc

For a = 2 To DocCount

MyName = Dir()

MyDoc(a) = MyName

Next a

For a = 1 To DocCount

Documents.Open MyPath & MyDoc(a)

ActiveWindow.ActivePane.View.Type = wdPageView

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

NormalTemplate.AutoTextEntries("Filename").Insert Where:=Selection.Range

'insert the file name in the header

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDate

Selection.TypeText Text:=vbTab

Selection.InsertDateTime DateTimeFormat:="dd/MM/yyyy HH:mm:ss", _

InsertAsField:=True

'insert an updating time field in the header

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Documents.Save NoPrompt:=True, OriginalFormat:=wdOriginalDocumentFormat

'save the document

Documents.Close

'close the document

Next a

End Sub



Try it out first on a couple of test docs to see if it does what you want
(you don't want to be correcting 220 documents. (change the DocCount to the
number of test documents)

Evi
 

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