| 
    
     |  | 遅くなりました 皆様、
 色々な情報、検証ありがとうございます
 
 
 APIについては、
 他含めて、とりあえずメモさせて頂き
 CreateFile が失敗するとき
 ://www.moug.net/faq/viewtopic.php?t=32692
 等あわせて、勉強させて頂きます
 
 後日、APIでのQあった時にアドバイス頂けると嬉しいです
 よろしくお願い致します
 
 
 ▼熊谷隆史 さん:
 >単なる報告ですので、見て頂けたなら結構です。
 お知らせ頂き嬉しいです
 ありがとうございました
 
 URLの件 コメントありがとうございます
 
 >今のMougは、書き込みが減少傾向にあるようで
 >回答者さんも質問者さんも離れているので、
 >私もたまに見に来る程度です。
 そんな気がしていました
 私の場合は、書き込みできないのでやむを得ずでしたが
 やはり、寂しい〜 です
 
 
 今回の処理とあわせて
 気になっている方もいらっしゃるかもしれないので
 >このスレッドで最初に提示して(削除してしまった)を
 kanabunさん 勝手で申し訳ないですが、再掲示させて頂きます
 
 
 今回処理
 
 Public Sub get_job(myPath As String, strFind As String)
 'Dim myPath As String
 'Dim strFind As String
 Dim f As String
 Dim n&
 Dim myList() As String
 
 Dim cnt
 
 'myPath = "D:\(Data)"
 'strFind = "abc.*"
 FindFile myPath, strFind, myList(), n '★呼び出し
 
 If n = 0 Then
 
 'Debug.Print "無し"
 
 ElseIf n = 1 Then
 
 'Debug.Print n & " 件"
 'Debug.Print Join(myList, vbCr)
 '実際の処理 ブックを開く等
 
 Else
 
 'Debug.Print n & " 件"
 'Debug.Print Join(myList, vbCr)
 'Debug.Print "重複"
 
 End If
 
 End Sub
 
 
 このスレッドで最初に提示して(削除してしまった)の書き込み
 
 【58200】Re:再帰処理でのファイル検索
 
 発言[NEW] kanabun - 08/10/10(金) 21:09 -
 
 引用なし
 パスワード
 ▼ON さん:
 
 >Application.FileSearch
 >でのフォルダ、ファイルの検索が遅いので
 
 それに、最新版Excel2007では、いまのところ使えないですしね(-_-)
 
 >ファイルサーバーの所定のフォルダ配下には
 
 以下のサンプルの
 > Sub Try_Start()
 内の
 >  myPath = "D:\(Data)"
 >  strFind = "abc.*"
 を、ファイルサーバーへのパスと 検索したいファイル名に置き換えて
 お試しください。
 
 '---------------------------------------------
 Option Explicit
 
 Private Const MAX_PATH = 260
 Private Const INVALID_HANDLE_VALUE = (-1)
 
 ' WIN32_FIND_DATA構造体 (Unicodeバージョン)
 Private Type WIN32_FIND_DATA
 dwFileAttributes  As Long
 ftCreationTime   As Currency
 ftLastAccessTime  As Currency
 ftLastWriteTime   As Currency
 nFileSizeHigh    As Long
 nFileSizeLow    As Long
 dwReserved0     As Long
 dwReserved1     As Long
 cFileName(1 To MAX_PATH * 2) As Byte 'Unicode
 cAlternate(1 To 14 * 2) As Byte    'Unicode
 End Type
 
 
 Private Declare Function FindFirstFile _
 Lib "kernel32" Alias "FindFirstFileW" _
 (ByVal lpFileName As Long, _
 lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindNextFile _
 Lib "kernel32" Alias "FindNextFileW" _
 (ByVal hFindFile As Long, _
 lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindClose _
 Lib "kernel32" _
 (ByVal hFindFile As Long) As Long
 
 '-------------------------------------------------------------
 
 Sub Try_Start()
 Dim myPath As String
 Dim strFind As String
 Dim f As String
 Dim n&
 Dim myList() As String
 
 myPath = "D:\(Data)"
 strFind = "abc.*"
 FindFile myPath, strFind, myList(), n '★呼び出し
 
 If n Then
 MsgBox Join(myList, vbCr), , strFind & " ---> " & n & " Files"
 Else
 MsgBox "該当ファイルなし"
 End If
 
 End Sub
 
 
 Private Sub FindFile(Pathname$, strFind$, myList$(), _
 fCount&, Optional SearchChild As Boolean = True)
 Dim p As String
 Dim fDATA As WIN32_FIND_DATA
 Dim f As String
 Dim hFile As Long
 
 If Right$(Pathname, 1) <> "\" Then Pathname = Pathname & "\"
 strFind = Lcase$(strFind)
 p = Pathname & "*.*"
 
 hFile = FindFirstFile(StrPtr(p), fDATA)
 If hFile = INVALID_HANDLE_VALUE Then Exit Sub
 Do
 f = fDATA.cFileName
 f = Left$(f, InStr(f, vbNullChar) - 1)
 If (fDATA.dwFileAttributes And vbDirectory) = 0 Then '<File> なら
 If Lcase$(f) Like strFind Then
 fCount = fCount + 1
 ReDim Preserve myList(1 To fCount)
 myList(fCount) = Pathname & f
 End If
 
 ElseIf Left$(f, 1) <> "." Then        '<Directory>なら
 If SearchChild Then
 FindFile Pathname & f, strFind, myList(), fCount
 End If
 End If
 Loop While FindNextFile(hFile, fDATA)
 FindClose hFile
 
 End Sub
 
 |  |