ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   listing the names of files (https://www.excelbanter.com/excel-programming/330545-re-listing-names-files.html)

theDude[_4_]

listing the names of files
 

Hi Tim,

It appears no one has provided a solution for you. I've been
unavailable for a while, so sorry for the delay...

This may work for you (it's untested); see my addional code added in
BOLD:

Code:
--------------------
Sub ConvertFiles()
Dim vrtSelectedItem As Variant
Dim FileToOpen As String
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
fd.Title = "Cool Application"
fd.InitialFileName = "My Documents"
If fd.Show = -1 Then
For a = 1 To fd.SelectedItems.Count
MsgBox fd.SelectedItems(a)
Dim NextFile As String

NextFile = Dir(fd.SelectedItems(a) & "\*detail*.*")
Workbooks.Open Filename:=NextFile
ActiveWorkbook.SaveAs Filename:= _
NextFile & ".wk4", _
FileFormat:=xlWK4, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
NextFile = Dir()

Do While NextFile < ""
Workbooks.Open Filename:=NextFile
ActiveWorkbook.SaveAs Filename:= _
NextFile & ".wk4", _
FileFormat:=xlWK4, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
NextFile = Dir()
Loop
Next
' CREATE A NEW WORKBOOK AND LIST/COUNT FILES...
WORKBOOKS.ADD
FOR A = 1 TO FD.SELECTEDITEMS.COUNT
' ADD FILE NAME TO SHEET...
ACTIVESHEET.CELLS(A, 1).VALUE = FD.SELECTEDITEMS(A)
NEXT A
' ADD FILE COUNT TO SHEET...
ACTIVESHEET.CELLS(A + 1, 1).VALUE = \"TOTAL FILES: \" & FD.SELECTEDITEMS.COUNT
End If
End Sub
--------------------

Hope this helps,
theDude


--
theDude
------------------------------------------------------------------------
theDude's Profile: http://www.excelforum.com/member.php...o&userid=16550
View this thread: http://www.excelforum.com/showthread...hreadid=372302



All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com