Replacing Application.Filesearch in Excel 2010

If you are using Excel 2010 or later versions, you might have noticed that the Application.Filesearch method is no longer available. This method was commonly used to search for files in a directory using VBA code. However, Microsoft has removed this feature due to security concerns.

So, if you are facing issues with the Application.Filesearch method, you need to find an alternative solution. Here are some options that you can consider:

1. Use the Dir function: The Dir function can be used to search for files in a directory. You can use this function in a loop to search for all the files in a directory. Here’s an example code:

Dim strFile As String
strFile = Dir(“C:MyFolder*.*”)
Do While strFile <> “”
‘Do something with the file
strFile = Dir
Loop

2. Use the FileSystemObject: The FileSystemObject is a powerful tool that can be used to perform various file operations. You can use this object to search for files in a directory. Here’s an example code:

Dim fso As Object
Dim fld As Object
Dim strFile As String

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set fld = fso.GetFolder(“C:MyFolder”)

Conclusion

Athena Estudy

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top