Help with App.FileSearch object, please?

E

Ed

I'm trying to loop through the files in a folder to use FileCopy. The files
have no dot-extension suffix, and FIleSearch can't see them. If I rename
them with a .doc, it works great. Can someone help me tweak this? Or give
me a better method?

Ed

With fs
.LookIn = strPath & "\MyDocs"
.FileName = "*.doc" 'for no extension,
'I used "*"

If .Execute > 0 Then 'with no extension,
'this drops immediately to End If
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
strName = .FoundFiles(i)
strFName = Right(strName, Len(strName) - 9)
MsgBox strFName
FileCopy strName, strFolder & strFName
Next i
End If
End With
 
P

Pete Bennett

Might be a stupid question, but have you tried using "*.*" as your search
filter?
 
E

Ed

Hi, Pete. Not stupid at all - I've been caught by things just like that.
But yes, I did try it - but there's no . in the name at all. I did get
something that worked:

Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder _
(strTIRs)
If Not objFolder Is Nothing Then
For Each objFile In objFolder.Files
With objFile
strName1 = .Name
FileCopy strTIRs & "\" & strName1, strFolder & "\" &
strName1
End With
Next
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top