Dim pFilename as string
pFilename = dir("c:\....[folder]\*.doc")
Do while len(pFilename) > 0
.... call macro using pFilename
pFilename = dir
Loop
"V" <V...@discussions.microsoft.com> wrote in message
news:A85D3D48-17B7-4A51...@microsoft.com...
> I need to run the same macro created in Word (search and replace text
macro)
> on 500 files in a directory. Is there a way I can tell the macro to go run
on
> each of those files?
"Helmut Weber" <anon...@discussions.microsoft.com> wrote in message
news:4cec01c48041$ef0db8e0$a401...@phx.gbl...
I guess if you're really worried about it you could use the Dir loop to
collect the file names into an array or a collection, then iterate that as a
separate operation.
"Helmut Weber" <anon...@discussions.microsoft.com> wrote in message
news:4da701c48051$424e23a0$a601...@phx.gbl...
Dans son message, < Helmut Weber > écrivait :
In this message, < Helmut Weber > wrote:
|| Hi Jezebel,
|| using dir() and processing the returned files
|| you may find, that in some cases a file is processed
|| more than once, as Jean-Guy Marcil mentioned. See:
||
http://groups.google.com/groups?hl=de&lr=&ie=UTF-8&threadm=uQq7c%24uWEHA.3716%
|| 40TK2MSFTNGP11.phx.gbl&rnum=1&prev=/groups%3Fas_q%3Ddir%
|| 26ie%3DUTF-8%26as_ugroup%3Dmicrosoft.public.word.vba*%
|| 26as_uauthors%3DJean-Guy%2520%26lr%3D%26hl%3Dde
|| ---
|| Thread is "saving files as pdf" by Chad Demeyer.
In fact, I was copying the content of a folder to a new one, then opening
each file in turn to generate a pdf. In this particular case, as you and
Jezebel suggested, I had the problem because I as mucking with the folder's
content.
By the way, Helmut, in case you did not know this resource, you may want to
check out
http://tinyurl.com/
so that the monstrous URL above becomes:
http://tinyurl.com/5jo6z
Cheers!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarci...@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org