2016-11-14 32 views
0

我正在制作一个.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

+0

您发布的代码中没有函数或过程'FolderPath'。其中唯一的'FolderPath'是过程'ProcessFolder'的一个参数(它使用未定义的变量'fldr'的属性)。 –

+0

FolderPath“C:\我的文档”是它出错的地方。 –

+0

是的,你已经提到过。 –

回答

0
Folderpath="c:\windows" 

您错过了等号。

+0

等号导致它不会出现类型不匹配的错误,但它没有执行任何操作(无消息框) –

+0

帮助在https://www.microsoft.com/zh-cn/download/details.aspx?id = 8247 – noodles

+0

他们似乎已经把5.6降低了5.7。 – 2016-11-15 06:36:24

相关问题