Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching folders & putting powerpoint filename into a Word Doc 1

Status
Not open for further replies.

ftpdoo

Programmer
Aug 9, 2001
202
GB
Hi,

I've got a set of subfolders labeled:

A-E F-M N-P Q-Z

Stored in these folders is powerpoint documents. I'm trying to get the filenames of each of these powerpoint documents and place them into a word document.

Any ideas??
Thanks,
Jonathan
 
To get you started...
Would be a lot simpler if the sub directory names are fixed

Dim sParentDir As String
Dim sSubDir As String
Dim cSubDirs As Collection
Dim sFile As String
Dim i As Long

Dim sDoc As String
Dim oDoc As Word.Document
Dim oPara As Word.Paragraph

sDoc = "C:\test.doc"

sParentDir = "C:\WINDOWS\Profiles\K26479"

Set cSubDirs = New Collection
sSubDir = Dir(sParentDir & "\*", vbDirectory)
Do While sSubDir <> &quot;&quot;
cSubDirs.Add sParentDir & &quot;\&quot; & sSubDir
sSubDir = Dir
DoEvents
Loop

Set oDoc = New Word.Document

For i = 1 To cSubDirs.Count
sFile = Dir(cSubDirs(i) & &quot;\*.ppt&quot;)
Do While sFile <> &quot;&quot;
Debug.Print sParentDir & &quot;\&quot; & sFile
Set oPara = oDoc.Paragraphs.Add
oPara.Range.Text = sParentDir & &quot;\&quot; & sFile & vbCr
Set oPara = Nothing
sFile = Dir
DoEvents
Loop
Next i

Set cSubDirs = Nothing


oDoc.SaveAs sDoc
oDoc.Close
Set oDoc = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top