Created
April 5, 2012 02:59
-
-
Save nobrinskii/2307652 to your computer and use it in GitHub Desktop.
[vba/excel] フォルダに存在するファイルの名前一覧を取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'------------------------------------------------------------------------------ | |
'フォルダに存在するファイルの名前一覧を取得する | |
'------------------------------------------------------------------------------ | |
'【引数】ファイル名を格納するDictionary、検索するパス | |
'【戻り値】 | |
'【備考】引数のDictionaryにファイル名を格納する。 | |
' サブフォルダは考慮しない。 | |
Private Sub GetExistingFileNames(dicFileName As Object, strPath As String) | |
Dim FSO As Object | |
Dim objFile As Object | |
Set FSO = CreateObject("Scripting.FileSystemObject") | |
If Not FSO.FolderExists(strPath) Then | |
Exit Sub | |
End If | |
For Each objFile In FSO.GetFolder(strPath).Files | |
If Not dicFileName.Exists(objFile.Name) Then | |
dicFileName.Add objFile.Name, "" | |
End If | |
Next objFile | |
Set FSO = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment