A tried and true method, not dependent on the FSO:
To get it into code to run: press [Alt]+[F11] to open the VB Editor, use the
VB editors menu to Insert | Module and copy the code below and paste it into
the code module. Close the VB editor. Choose Tools | Macro | Macros from
the main Excel menu and run the ExportFileNames macro.
Sub ExportFilenames()
Const basicPath = "Y:\ReleasedDrawings\"
'change worksheet name and
'starting cell
'as needed for your workbook
Const wsName = "Sheet1"
Const startCell = "A2"
Dim anyFilename As String
Dim anyRange As Range
Dim rOffset As Long
rOffset = Cells(Rows.Count, Range(startCell).Column).End(xlUp).Row - 1
Set anyRange = Worksheets(wsName).Range(startCell)
Worksheets(wsName).Select
Application.ScreenUpdating = False ' improves speed
anyFilename = Dir$(basicPath & "*.*", vbNormal)
Do Until anyFilename = ""
anyRange.Offset(rOffset, 0) = anyFilename
rOffset = rOffset + 1
anyFilename = Dir$()
Loop
anyRange.Select
Application.ScreenUpdating = True
End Sub
I would like to export file name from "Y:\ReleasedDrawings" to excel.
Can someone help me out?
Thanks
Vedat- Hide quoted text -
- Show quoted text -