本文介绍了如何解决用户自定义类型未定义的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是在文件夹中搜索诸如"requirements"之类的文件夹的过程.当开始逐步操作时,由于FileSystemObject
,我收到一条错误消息:
Below is a procedure to search folder for a folder like "requirements". When beginning to step through I receive an error message because of FileSystemObject
:
我想念什么?
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
(早期绑定),而未在项目参考"中指定对其的引用.
You are trying to use FileSystemObject
(early binding) without specifying the reference to it in the Project References.
您需要添加Microsoft Scripting Runtime
参考,如以下屏幕截图所示:
You need to add Microsoft Scripting Runtime
reference as can be seen in the screen-shot below:
这篇关于如何解决用户自定义类型未定义的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!