I have done extensive search on internet but still was not able to find the solution. The interesting thing is that my code worked before. I am using html page with VBScript code, opened using IE 9.
My code is below:
29: Function TraverseDirectory(objFolder, searchTerm, outFile)
30: if objFolder.SubFolders.Count > 0 then <-- ERROR shown in this line: Object required: 'objFolder'
31: MsgBox objFolder.SubFolders.Count <-- This message is shown without an issue
32: Set fc = objFolder.SubFolders
33: For Each f1 in fc
34: ProcessFolder f1, searchTerm, outFile
35: TraverseDirectory f1, searchTerm, outFile
36: Next
37: else
38: ProcessFolder objFolder, searchTerm, outFile
39: end if
40: End Function
I am showing the error in line 30: Object required 'objFolder'
I added a message box in line 31 and it was reached, outputting message box with a number of subfolders in a give folder. If the problem was actually in line 30, it would never reach line 31. If I completely remove line 31 (the one with a message box), I still get the same error in line 30.
My function above is called the following way:
Set objFolder = objFSO.GetFolder("C:\Test")
TraverseDirectory objFolder, str, outFile
The folder exists and is retrieved without a problem. Not sure what is happening. Can someone shed some light on the issue?
objFoldervariable. Can you test this by changingobjFolderto something unique in the function, likeobjFolderInsideFunction?MSGBOX VarType( objFolder) & vbTab & TypeName(objFolder)between lines 29 and 30 and before the firstTraverseDirectory?Set fc = objFolder.SubFolders For each f1 in fcthe output come out as "8 String" instead of "8 Folder"