View Single Post
  #3   Report Post  
Posted to microsoft.public.word.newusers
Linda RQ[_2_] Linda RQ[_2_] is offline
external usenet poster
 
Posts: 2
Default File location auto text

Thanks Doug. The documents are on a network drive. Does that require any
additional text? I printed this and the Macro Instructions so when I get to
work tomorrow, it will be sitting there ready for me to try it. The "What
to do with a Macro" article is a great thing to add to this...I have worked
with very few macros and needed to be pulled along each step.

Linda


"Doug Robbins - Word MVP" wrote in message
...
If you have all of the documents in a folder, running a macro containing
the following code will add the path and filename to the primary footer of
the first section of the document. Change the C:\test to whereever you
have the documents.

Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
Dim myrange As Range

PathToUse = "C:\Test\"
'Set the directory and type of file to batch process
myFile = Dir$(PathToUse & "*.doc")
While myFile ""
'Open document
Set myDoc = Documents.Open(PathToUse & myFile)
Set myrange = myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange
myrange.Collapse wdCollapseStart
myDoc.Fields.Add myrange, wdFieldEmpty, "Filename \p"
myrange.Fields.Update
'Close the modified document after saving changes
myDoc.Close SaveChanges:=wdSaveChanges
'Next file in folder
myFile = Dir$()
Wend

See the article "What do I do with macros sent to me by other newsgroup
readers to help me out?" at:

http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Linda RQ" wrote in message
...
Hi everyone,

Before I open up each document and do this one at a time I was wondering
if there is a way to add the auto text for file location to my documents
all at once?

I have about 100 documents in the same folder. The process I am planning
is to open the document/insert file location into the header or
footer/print each document. This is so 10 people have copies and the
group can determine which documents will be kept and which ones will go.

Thanks,
Linda