excelä¸ç¨vbaå®ç°èªå¨æåæ件夹å çæ件åçæ¹æ³å¦ä¸ï¼
1ãæ°å»ºä¸ä¸ªvbaå®èæ¬
2ãåå
¥å¦ä¸ä»£ç ï¼
Function GetFileList(FileSpec As String) As Variant
' Returns an array of filenames that match FileSpec
' If no matching files are found, it returns False
Dim FileArray() As Variant
Dim FileCount As Integer
Dim FileName As String
On Error GoTo NoFilesFound
FileCount = 0
FileName = Dir(FileSpec)
If FileName = "" Then GoTo NoFilesFound
' Loop until no more matching files are found
Do While FileName <> ""
FileCount = FileCount + 1
ReDim Preserve FileArray(1 To FileCount)
FileArray(FileCount) = FileName
FileName = Dir()
Loop
GetFileList = FileArray
Exit Function
' Error handler
NoFilesFound:
GetFileList = False
End Function
3ãä¼ å ¥æ件路å¾å°±å¯ä»¥è·åæ件åå°æå®çexcelè¡¨æ ¼ä¸
4ãç»æï¼