Skip to content

Instantly share code, notes, and snippets.

@nobrinskii
Created April 5, 2012 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nobrinskii/2307652 to your computer and use it in GitHub Desktop.
Save nobrinskii/2307652 to your computer and use it in GitHub Desktop.
[vba/excel] フォルダに存在するファイルの名前一覧を取得する
'------------------------------------------------------------------------------
'フォルダに存在するファイルの名前一覧を取得する
'------------------------------------------------------------------------------
'【引数】ファイル名を格納する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