Greetings,
I am relatively new to vba and am looking for a way to search through a network and find a single file. I believe I have found it, however, I am unable to make the code run because I continually get the Object 91 error.
In the picture you can see the code that I am trying to get to work. It uses the Microsoft scripting run time reference.
The object is clearly defined as
Dim oStartFolder as Scripting folder
and the string to the folder I want to start as is likewise clearly defined. So, I am not sure what I am missing.
Any help would be greatly appreciated.
Thanks
Sub FindFile()
Dim oFolderStart As String
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Dim oStartFolder As Scripting.Folder
Dim newfolderpath As String
Dim subfol As Scripting.Folder
oFolderStart = "T:\02 ESTIMATING & SALES\03 JOBS IN PROCESS"
newfolderpath = "T:\TempDesignWorksheet"
Set oStartFolder = fso.GetFolder(oFolderStart)
For Each fil In oStartFolder.Files
If Left(fso.GetFileName(fil.Path), 5) = "18000" And Left(fso.GetExtensionName(fil.Path), 2) = "xl" Then
fil.Copy newfolderpath & "\" & fil.Name
End If
Next fil
'For Each subfol In oStartFolder.SubFolders
'FindFile (subfol.Path)
'Next subfol
End Sub
Bookmarks