[VBA-EXCEL]Lister les fichiers d';un répertoire donné
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[VBA-EXCEL]Lister les fichiers d';un répertoire donné相关的知识,希望对你有一定的参考价值。
Comment lister tous les fichiers d'un répertoire dans un fichier excel ?Excel (VBA) list all filenames in a directory
mastipro
Sub ListAllFile() Dim objFSO As Object Dim objFolder As Object Dim objFile As Object Dim ws As Worksheet Set objFSO = CreateObject("Scripting.FileSystemObject") Set ws = Worksheets.Add 'Get the folder object associated with the directory Set objFolder = objFSO.GetFolder("C:") ws.Cells(1, 1).Value = "The files found in " & objFolder.Name & "are:" 'Loop through the Files collection For Each objFile In objFolder.Files ws.Cells(ws.UsedRange.Rows.Count + 1, 1).Value = objFile.Name Next 'Clean up! Set objFolder = Nothing Set objFile = Nothing Set objFSO = Nothing End Sub
以上是关于[VBA-EXCEL]Lister les fichiers d';un répertoire donné的主要内容,如果未能解决你的问题,请参考以下文章