i am using â?¬office 97 upwards.

Cansomeone asist me with some code which looks in a particular folder, opens
each document one by one and does something then saves it and closes it and
open next document.

Open each doc in folder 1 by 1

with active doc

do something

save document

close document

next document


--
Mark

Re: Open all docs in folder by Jezebel

Jezebel
Fri Mar 31 05:31:40 CST 2006

Dim pFileName as string
Dim pDoc as Word.Document

pFileName = Dir("C:\MyFolder\*.doc")
Do until len(pFileName) = 0
set pDoc = Documents.Open(pFileName)
... do whatever with pDoc
pDoc.Close SaveChanges:=TRUE
pFileName = Dir
Loop






"Mark" <Mark@discussions.microsoft.com> wrote in message
news:1CB9E09C-03E0-43D7-88C2-789FD92897D8@microsoft.com...
>i am using ?office 97 upwards.
>
> Cansomeone asist me with some code which looks in a particular folder,
> opens
> each document one by one and does something then saves it and closes it
> and
> open next document.
>
> Open each doc in folder 1 by 1
>
> with active doc
>
> do something
>
> save document
>
> close document
>
> next document
>
>
> --
> Mark



Re: Open all docs in folder by Mark

Mark
Fri Mar 31 07:34:01 CST 2006

Thanks,

i have tried this and altered the folder path to suit, it finds the first
file and then debugs on the 'set pDoc = Documents.Open(pFileName)' line with
a run-time rror 5174 'this file could not be found'.

Try one of the following
Check spelling of the document
Try a different filename

Equally when I change the path to 'R' drive (a network drive) it doesn't
find anything and end subs.

Any ideas?
--
Mark


"Jezebel" wrote:

> Dim pFileName as string
> Dim pDoc as Word.Document
>
> pFileName = Dir("C:\MyFolder\*.doc")
> Do until len(pFileName) = 0
> set pDoc = Documents.Open(pFileName)
> ... do whatever with pDoc
> pDoc.Close SaveChanges:=TRUE
> pFileName = Dir
> Loop
>
>
>
>
>
>
> "Mark" <Mark@discussions.microsoft.com> wrote in message
> news:1CB9E09C-03E0-43D7-88C2-789FD92897D8@microsoft.com...
> >i am using ?office 97 upwards.
> >
> > Cansomeone asist me with some code which looks in a particular folder,
> > opens
> > each document one by one and does something then saves it and closes it
> > and
> > open next document.
> >
> > Open each doc in folder 1 by 1
> >
> > with active doc
> >
> > do something
> >
> > save document
> >
> > close document
> >
> > next document
> >
> >
> > --
> > Mark
>
>
>

Re: Open all docs in folder by Doug

Doug
Fri Mar 31 08:41:21 CST 2006

You need to use:

Dim pFileName As String
Dim pDoc As Word.Document

pFileName = Dir("C:\MyFolder\*.doc")
Do Until Len(pFileName) = 0
MsgBox pFileName
Set pDoc = Documents.Open("C:\MyFolder\" & pFileName)
pFileName = Dir
Loop


--
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

"Mark" <Mark@discussions.microsoft.com> wrote in message
news:1CD07C74-C527-4E38-BC25-ECBF2A14C627@microsoft.com...
> Thanks,
>
> i have tried this and altered the folder path to suit, it finds the first
> file and then debugs on the 'set pDoc = Documents.Open(pFileName)' line
> with
> a run-time rror 5174 'this file could not be found'.
>
> Try one of the following
> Check spelling of the document
> Try a different filename
>
> Equally when I change the path to 'R' drive (a network drive) it doesn't
> find anything and end subs.
>
> Any ideas?
> --
> Mark
>
>
> "Jezebel" wrote:
>
>> Dim pFileName as string
>> Dim pDoc as Word.Document
>>
>> pFileName = Dir("C:\MyFolder\*.doc")
>> Do until len(pFileName) = 0
>> set pDoc = Documents.Open(pFileName)
>> ... do whatever with pDoc
>> pDoc.Close SaveChanges:=TRUE
>> pFileName = Dir
>> Loop
>>
>>
>>
>>
>>
>>
>> "Mark" <Mark@discussions.microsoft.com> wrote in message
>> news:1CB9E09C-03E0-43D7-88C2-789FD92897D8@microsoft.com...
>> >i am using ?office 97 upwards.
>> >
>> > Cansomeone asist me with some code which looks in a particular folder,
>> > opens
>> > each document one by one and does something then saves it and closes it
>> > and
>> > open next document.
>> >
>> > Open each doc in folder 1 by 1
>> >
>> > with active doc
>> >
>> > do something
>> >
>> > save document
>> >
>> > close document
>> >
>> > next document
>> >
>> >
>> > --
>> > Mark
>>
>>
>>