我正在尝试使用 FileSystemObject 打开一个文件,但是当我尝试运行它时,系统什么也不做。不显示调试,没有运行时错误,不编译。它只是保持原样。我还检查了参考资料中的“MS Scripting Runtime”。以下是我为此使用的代码:
Sub fsoobject()
Dim fso As New FileSystemObject, f As Folder, sf As Folder, myFile As File
Set f = fso.GetFolder("C:\Users\jpmehta\Desktop")
For Each sf In f.SubFolders
For Each mySubFolder In myFolder.SubFolders
For Each myFile In mySubFolder.Files
If myFile.Name Like "Done" Then
MsgBox myFile.Name
Exit For
End If
Next
MsgBox "Else"
Next
Next
End Sub