EA_FindPath

機能説明
指定したディレクトリ配下のファイルの一覧を取得します。

定義
Public Function EA_FindPath (
ByVal ea_path As String,
ByVal ea_filter As String,
ByRef ea_plist() As String,
ByVal ea_f As Integer,
Optional ByRef ea_cnt As Long,
Optional ByVal ea_fcnt As Integer
) as Integer

引数
ea_path
ファイル検索の対象となるディレクトリパスを指定します。
ea_filter
ファイル検索対象のフィルタを指定します。
ea_plist()
検索結果のファイル一覧が格納されます。
ea_f
ディレクトリ配下の検索階層を指定します。
0 :指定ディレクトリ配下を全て検索します。
1〜:検索が有効となる下階層ディレクトリ数を指定します。
ea_cnt
未使用(Optional指定のため、値の設定は不要)
※この引数は、関数内の再起処理のために使用しています。
ea_fcnt
未使用(Optional指定のため、値の設定は不要)
※この引数は、関数内の再起処理のために使用しています。

戻り値
指定ディレクトリ配下で確認されたファイルの件数が返却されます。

使用例
フォルダ選択ダイアログで指定したフォルダ配下から指定した条件に一致するファイルの一覧を取得し、ワークシート(Sheet1)に出力します。
                                    
Sub Main()
    Dim ea_WkSh As Worksheet
    Dim ea_path As String
    Dim ea_plist() As String
    Dim ea_fcnt As Integer
    Dim ea_res As Integer
    Dim ea_i As Integer
    
    Set ea_WkSh = ThisWorkbook.Worksheets("Sheet1")
    ea_fcnt = funcFolderSelectDlg2(ea_path)
    MsgBox "選択件数:" & ea_fcnt & vbCrLf & "選択パス:" & ea_path
    If ea_fcnt = 0 Then Exit Sub
    
    ea_res = EA_FindPath(ea_path, "*.csv", ea_plist(), 0)
    If ea_res <> 0 Then
        For ea_i = 0 To UBound(ea_plist)
            ea_WkSh.Cells(ea_i + 1, 1) = ea_plist(ea_i)
        Next
    End If
    
    Set ea_WkSh = Nothing
End Sub
                                    
                                

クラウドソーシング「ランサーズ」