I have several hundred Word documents in a network folder
(G:\Marketing\Updates) that I need to update with the same information. I've
created a procedure to do this to one document at a time, but I could save a
ton of time by having it automatically open each document in that folder, run
the procedure, save it, close it, then open the next one, etc.

Could someone help me with the code I need to do this? Thanks!
--
Steve C

Re: Updating Multiple Documents in a Folder by Graham

Graham
Wed Apr 09 07:17:24 PDT 2008

The basic batch code is

Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
PathToUse = "G:\Marketing\Updates\"
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
myFile = Dir$(PathToUse & "*.do?")

While myFile <> ""
Set myDoc = Documents.Open(PathToUse & myFile)
'****************************************
'Do your stuff here
'****************************************
myDoc.Close SaveChanges:=wdSaveChanges
myFile = Dir$()
Wend


Steve C wrote:
> I have several hundred Word documents in a network folder
> (G:\Marketing\Updates) that I need to update with the same
> information. I've created a procedure to do this to one document at
> a time, but I could save a ton of time by having it automatically
> open each document in that folder, run the procedure, save it, close
> it, then open the next one, etc.
>
> Could someone help me with the code I need to do this? Thanks!



Re: Updating Multiple Documents in a Folder by Helmut

Helmut
Wed Apr 09 07:21:12 PDT 2008

Hi Steve,

see:
http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm
see also:
http://gregmaxey.mvps.org/Process_Batch_Folder.htm

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: Updating Multiple Documents in a Folder by SteveC

SteveC
Wed Apr 09 08:29:00 PDT 2008

Graham & Helmut:

Thanks much for the help and your quick response!

--
Steve C


"Graham Mayor" wrote:

> The basic batch code is
>
> Dim myFile As String
> Dim PathToUse As String
> Dim myDoc As Document
> PathToUse = "G:\Marketing\Updates\"
> If Documents.Count > 0 Then
> Documents.Close SaveChanges:=wdPromptToSaveChanges
> End If
> myFile = Dir$(PathToUse & "*.do?")
>
> While myFile <> ""
> Set myDoc = Documents.Open(PathToUse & myFile)
> '****************************************
> 'Do your stuff here
> '****************************************
> myDoc.Close SaveChanges:=wdSaveChanges
> myFile = Dir$()
> Wend
>
>
> Steve C wrote:
> > I have several hundred Word documents in a network folder
> > (G:\Marketing\Updates) that I need to update with the same
> > information. I've created a procedure to do this to one document at
> > a time, but I could save a ton of time by having it automatically
> > open each document in that folder, run the procedure, save it, close
> > it, then open the next one, etc.
> >
> > Could someone help me with the code I need to do this? Thanks!
>
>
>