How to open, change & close files in selected directory.

A

Arawn

I need to be able to open a selected directory with *.doc's and
manipulate them one at a time, then save & close. I have been able to
do this in Excel, by putting the filenames into a worksheet and then
referencing the range, but I dont know how to get the filenames from
Word into a useful collection. I am using MS-Word 2003.

The form is already constructed for browsing and inputting the desired
directory.


Sub OpenDoStuffClose()
WD = TextBox1.Value '===== Working Directory =====

With Application.FileSearch
.NewSearch
.LookIn = WD
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For G = 1 To .FoundFiles.count
ReDim Names(G) As String
Names(G) = .FoundFiles(G)
Next G
End If
For LB = 1 To .FoundFiles.count
ListBox1.AddItem (.FoundFiles(LB))
Next LB
End With

FileCount = Application.FileSearch.FoundFiles.count
TextBox12.Value = FileCount

Do While i <= FileCount

COUNTX = ListBox1.ListCount

Application.Documents.Open FileName = ??????
i = i + 1
Loop
End Sub

Any help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top