What to do?
파일명 가져오기
msoFileDialogFolderPicker & Dir 함수 사용하기
Sub 파일명가져오기()
Dim 파일다이얼로그 As FileDialog
Dim 파일경로, 파일명 As String
Set 파일다이얼로그 = Application.FileDialog(msoFileDialogFolderPicker)
파일다이얼로그.Show
파일경로 = 파일다이얼로그.SelectedItems(1)
파일명 = Dir(파일경로 & "\*.*")
Do While 파일명 <> ""
Debug.Print 파일명
파일명 = Dir()
Loop
End Sub
msoFileDialogFilePicker 사용하기
Sub 파일명가져오기()
Dim 파일다이얼로그 As FileDialog
Dim 파일경로, 파일명 As String
Set 파일다이얼로그 = Application.FileDialog(msoFileDialogFilePicker)
파일다이얼로그.Show
For Each 파일경로 In 파일다이얼로그.SelectedItems
파일명 = 파일명추출하기(파일경로)
Debug.Print 파일명
Next 파일경로
End Sub
Function 파일명추출하기(파일경로 As String)
Dim arr As Variant
arr = Split(파일경로, "\")
파일명추출하기 = arr(UBound(arr))
End Function
사실 CMD에서 dir /B /S > filePath.txt 명령어를 사용해도 됨
'VBA' 카테고리의 다른 글
[VBA] Layout 작업하기 (0) | 2022.12.26 |
---|