[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『フォルダも検索したい』(マーボー)
下はあるサイトで見つけたファイル検索のマクロを少しアレンジしたものですが フォルダの検索も同時に行うようにするにはどうしたら良いでしょうか
Sub ファイル検索()
Dim vntF As Variant Dim objFS As FileSearch Dim objFSO As FileSystemObject Dim dteDate As Date Dim GYO As Long Dim cntFound As Long
Set objFS = Application.FileSearch Set objFSO = New FileSystemObject Rows("8:65536").ClearContents GYO = 7 With objFS .NewSearch .LookIn = Trim(Cells(2, 4).Value) .Filename = Trim(Cells(3, 4).Value) dteDate = DateAdd("m", Cells(4, 4).Value * -1, Date) .SearchSubFolders = True If .Execute() <> 0 Then
For Each vntF In .FoundFiles
With objFSO.GetFile(vntF)
If .DateLastModified >= dteDate Then GYO = GYO + 1 Cells(GYO, 1).Value = .Name Cells(GYO, 2).Value = .DateLastModified Cells(GYO, 3).Value = _ Left(.Path, Len(.Path) - Len(.Name) - 1) cntFound = cntFound + 1 End If End With
Next vntF End If End With Set objFS = Nothing Set objFSO = Nothing
If cntFound = 0 Then MsgBox "見つかりません" Else MsgBox cntFound & "個見つかりました" End If End Sub
詳しいことはわかりませんがw この辺りは参考になりませんか? [[20050711132657]]『VBA:フォルダ名の取得』(いま) (キリキ)(〃⌒o⌒)b
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.