Creating an Array of Filenames (nice for looping through later):
Return to List
Public Sub Main()
Dim FileArray() As String, ffile As String, Count As Integer
Count = 0
With Dialogs(wdDialogFileOpen)
.Name = "*.*"
.Show
End With
ffile = Dir("*.*")
ReDim FileArray(Count)
FileArray(Count) = LCase(ffile)
Count = 1
Do While ffile <> ""
ffile = Dir()
If ffile <> "." And ffile <> ". ." Then
ReDim Preserve FileArray(Count)
FileArray(Count) = LCase(ffile)
Count = Count + 1
End If
Loop
For i = LBound(FileArray()) To UBound(FileArray())
Selection.InsertAfter Text:=FileArray(i) + Chr(13)
Selection.ExtendMode = False
Selection.MoveRight Unit:=wdCharacter, Count:=1
Next
Btn = MsgBox("There were" + Str(Count - 1) + " files listed.", vbOKOnly, " Results")
FINAL_EXIT:
End Sub