我正在制作一个.vbs文件,用于显示子文件夹中所有文件和文件的消息框以下是代码(它是更大脚本):当调用“FolderPath”(文件夹的路径)时出现类型不匹配错误
Set FSO = CreateObject("Scripting.FileSystemObject")
FolderPath "C:\My Documents"
Sub ProcessFolder(FolderPath)
Set Fls = fldr.Files
Set objFile = objFSO.CreateTextFile(outFile, True)
For Each thing In Fls
MsgBox thing.Path
Next
Set fldrs = fldr.SubFolders
Set objFile = objFSO.CreateTextFile(outFile, True)
For Each thing In fldrs
MsgBox thing.Path
ProcessFolder thing.Path
Next
End Sub
当我运行它,它在第3行(其中FolderPath
的叫法)的错误,他说:
类型不匹配:FOLDERPATH
您发布的代码中没有函数或过程'FolderPath'。其中唯一的'FolderPath'是过程'ProcessFolder'的一个参数(它使用未定义的变量'fldr'的属性)。 –
FolderPath“C:\我的文档”是它出错的地方。 –
是的,你已经提到过。 –