jmkite 发表于 2016-3-25 09:33
谢谢,可以提取文件名了,不过我想提取出来的文件名不要扩展名,研究你的代码,研究不到在那修改,请问如 ...
Sub 提取文件名_单击()
Dim Fso As Object, Drive As Object
Dim Fn As String, Fname As Object, Num As Integer
Dim subName As String, Disc As String
subName = [a1]
Disc = [a2]
Set Fso = CreateObject("Scripting.FileSystemObject")
Set folder = Fso.GetFolder(Disc)
For Each Fname In folder.Files
Fn = Fname.Name
If Fn Like "*." & subName Then
Num = Num + 1
Cells(Num + 3, 1) = Split(Fn, ".")(0)
End If
Next
End Sub