T
Tony
I have tried to right a macro to get the file nanes of the files in a dir on
my c; drive but only get \*.* as a results. And debug takes me to the
Print_file = dir() I can not get it to work. Can anyone tell me whats
incorrect in the file below.
Sub Print_Dir_Contents()
Dim Input_Dir, Print_File As String
Input_Dir = InputBox("Input the path containing the files you " & _
"want to list on your worksheet" & Chr(13) & Chr(13) & _
"for example:C:\My Documents\*.*")
If Input_Dir = "" Then Exit Sub
' If you want only to print a specific file type, you can
' substitute the "\*.*" with "*\.xl*"
' (for Excel files only) for the directory specified in the
' InputBox above.
If Application.OperatingSystem Like "*Win*" Then
Print_File = Dir(Input_Dir) & "\*.*"
End If
Range("a1").Select
Counter = 1
Do While Len(Print_File) > 0
Worksheets(ActiveSheet.Name).Cells(Counter, 1).Value = _
Print_File
Print_File = Dir()
Counter = Counter + 1
Loop
Thanks if you can help
Tony
my c; drive but only get \*.* as a results. And debug takes me to the
Print_file = dir() I can not get it to work. Can anyone tell me whats
incorrect in the file below.
Sub Print_Dir_Contents()
Dim Input_Dir, Print_File As String
Input_Dir = InputBox("Input the path containing the files you " & _
"want to list on your worksheet" & Chr(13) & Chr(13) & _
"for example:C:\My Documents\*.*")
If Input_Dir = "" Then Exit Sub
' If you want only to print a specific file type, you can
' substitute the "\*.*" with "*\.xl*"
' (for Excel files only) for the directory specified in the
' InputBox above.
If Application.OperatingSystem Like "*Win*" Then
Print_File = Dir(Input_Dir) & "\*.*"
End If
Range("a1").Select
Counter = 1
Do While Len(Print_File) > 0
Worksheets(ActiveSheet.Name).Cells(Counter, 1).Value = _
Print_File
Print_File = Dir()
Counter = Counter + 1
Loop
Thanks if you can help
Tony