User defined type not defined 如何解决?
How to solve the error User defined type not defined?
以下是在文件夹中搜索“requirements”等文件夹的过程。由于 FileSystemObject
:
开始逐步执行时,我收到一条错误消息
User defined type not defined
我错过了什么?
Sub GetSubFolders()
Dim f As Folder, sf As Folder, myFile As File
Dim fso As New FileSystemObject ' <=========== ERROR HERE
Set f = fso.GetFolder("C:\Users\C58227\Desktop\Projects\CRDs")
For Each sf In f.SubFolders
For Each mySubFolder In myFolder.SubFolders
For Each myFile In mySubFolder.Files
If myFile.Name Like "Requirements" Then
MsgBox myFile.Name
Exit For
End If
Next
MsgBox "Else"
Next
Next
End Sub
您正在尝试使用 FileSystemObject
(早期绑定),但未在项目引用中指定对它的引用。
您需要添加 Microsoft Scripting Runtime
参考,如下面的屏幕截图所示:
以下是在文件夹中搜索“requirements”等文件夹的过程。由于 FileSystemObject
:
User defined type not defined
我错过了什么?
Sub GetSubFolders()
Dim f As Folder, sf As Folder, myFile As File
Dim fso As New FileSystemObject ' <=========== ERROR HERE
Set f = fso.GetFolder("C:\Users\C58227\Desktop\Projects\CRDs")
For Each sf In f.SubFolders
For Each mySubFolder In myFolder.SubFolders
For Each myFile In mySubFolder.Files
If myFile.Name Like "Requirements" Then
MsgBox myFile.Name
Exit For
End If
Next
MsgBox "Else"
Next
Next
End Sub
您正在尝试使用 FileSystemObject
(早期绑定),但未在项目引用中指定对它的引用。
您需要添加 Microsoft Scripting Runtime
参考,如下面的屏幕截图所示: