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