Dim srcFile As String
srcFile = Dir("e:\AZL\A\5*" & "\A0?????." & yy & aa)
Do Until srcFile = ""
Open "e:\AZL\A\5*" & "\" & srcFile For Input As #FHandle ' 打开文件
srcFile = Dir
Loop
在这里"5*"的位置怎么处理?我要读A文件夹下的'5*'的100多个文件夹!
Dim srcFile As String
srcFile = Dir("e:\AZL\A\5*" & "\A0?????." & yy & aa)
Do Until srcFile = ""
Open "e:\AZL\A\5*" & "\" & srcFile For Input As #FHandle ' 打开文件
srcFile = Dir
Loop
在这里"5*"的位置怎么处理?我要读A文件夹下的'5*'的100多个文件夹!
既然没有多层子目录嵌套的问题,就简单多了:
Dim srcFile As String
Dim strSubDir() As String
Redim strSubDir(0)
srcFile = Dir("e:\AZL\A\5*", vbDirectory)
Do Until srcFile = ""
If strSubDir(0) = "" Then
strSubDir(0) = strFile
Else
Redim Preserve strSubDir(Ubound(strSubDir) + 1)
strSubDir(Ubound(strSubDir)) = strFile
End If
srcFile = Dir
Loop
For i = 0 To (Ubound(strSubDir))
srcFile = Dir("e:\AZL\A\" & strSubDir(i) & "\A0?????." & yy & aa)
Do Until srcFile = ""
Open "e:\AZL\A\" & strSubDir(i) & "\" & srcFile For Input As #FHandle '打开文件
srcFile = Dir
Loop
Next i