如题所述
温馨提示:答案为网友推荐,仅供参考
第1个回答 2021-02-19
遍历路径下所有文件,判断是否全是pdf的函数。供您参考。
Public Function fileCheck(dicPath As String)
Dim dotPos As Integer
Dim splitName As String
Set fsoOb = CreateObject("Scripting.FileSystemObject")
Set dicfile = fsoOb.GetFolder(dicPath).Files
fileCheck = False
For Each fn In dicfile
dotPos = InStrRev(fn.Name, ".")
splitName = Mid(fn.Name, dotPos + 1)
'MsgBox (LCase(splitName))
If splitName <> "pdf" Then
'MsgBox "文件拓展名只能为pdf,请保证本路径下只有pdf文件!"
fileCheck = True
Exit Function
End If
Next
End Function
本回答被网友采纳