Fix Excel Run-Time Error 445 in a PeopleSoft nVision Macro
Question details
Resolve run-time error 445 in an older PeopleSoft nVision StyleSheets macro that uses Application.FileSearch.

- Product
- Microsoft Excel and PeopleSoft nVision
- Device & OS
- not provided
- Scenario
- A user runs an older nVision StyleSheets macro in a newer version of Excel.
- Observed behavior
- The macro encounters run-time error 445 when it uses Application.FileSearch.
Open the affected workbook in desktop Excel and identify the folder and file pattern the macro is intended to search. Check with your PeopleSoft administrator before changing a vendor-supplied macro.
Replace Application.FileSearch with the VBA Dir function
Use Dir to enumerate matching files in a known folder without relying on the removed FileSearch object.
Application.FileSearch was available in older Excel versions but was removed starting with Excel 2007. Replace the entire FileSearch workflow, including properties such as LookIn and FoundFiles, rather than changing only the object name.
Dir searches one folder at a time. If the original macro searches subfolders or depends on sorted results, add equivalent handling or use a different enumeration method.
In Excel, open the Visual Basic Editor with Alt+F11. Find the nVision StyleSheets procedure and locate Application.FileSearch and its associated search properties and results loop.
Replace the FileSearch block with a Dir loop suited to your folder and file pattern. For example: Dim folderPath As String, fileName As String folderPath = "C:\Reports\" fileName = Dir(folderPath & "*.xls*") Do While fileName <> "" Debug.Print folderPath & fileName fileName = Dir() Loop
Inside the Do While loop, replace Debug.Print with the macro's original file-processing logic, using folderPath & fileName where the old code used a FoundFiles path. Set folderPath and the file pattern to match the original search.
In the Visual Basic Editor, select Debug > Compile VBAProject, then run the nVision macro against a controlled set of files and confirm it processes the expected results.

Replace FileSearch with FileSystemObject
Use FileSystemObject when the macro needs more control over folders and files, including subfolder traversal.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making everyday workbook migration straightforward. It does not repair the PeopleSoft nVision macro in Microsoft Excel.

Frequently Asked Questions
Why does Application.FileSearch cause an error in newer Excel versions?
Application.FileSearch was removed starting with Excel 2007. Older macros that depend on its object, properties, or methods need a replacement such as Dir or FileSystemObject.
Can Dir search subfolders automatically?
No. Dir searches the folder specified in its path. Add separate subfolder traversal or use FileSystemObject with recursive folder handling if the original macro searched subfolders.
How do I find the statement causing error 445?
When Excel displays the run-time error, select Debug if available. The Visual Basic Editor highlights the statement where execution stopped. Review that statement and the object it uses.
Should I change an Unload statement as well?
Only investigate Unload if debugging points to it or related code. Check the object being unloaded and whether it supports that action; replacing FileSearch does not automatically resolve a separate Unload issue.
Will WPS Office fix the PeopleSoft nVision macro?
No. WPS Office is an alternative for working with common Excel spreadsheet formats, but it does not repair the macro in Microsoft Excel. Review and test the VBA changes in the supported PeopleSoft and Excel environment.




