Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Error message when you run a macro to search for a file in an Office 2007 program: "Run-time error 5111"


Symptoms

You run a Microsoft Visual Basic for Applications (VBA) macro in a Microsoft Office 2007 program to search for a file on your computer. When you do this, you may receive the following VBA error message:
"Run-time error 5111

The command is not available on this platform"

↑ Back to the top


Cause

This issue occurs when you have 2007 Office programs installed on a Microsoft Windows XP computer, and the VBA macro uses the Application.FileSearch object. This object is no longer supported in 2007 Office programs.

↑ Back to the top


Workaround

To work around this issue, use the FileSystemObject object to recursively search directories and to find specific files. See the sample code that is provided in the following Microsoft Knowledge Base article:
185601 How to recursively search directories by using filesystemobject

↑ Back to the top


More Information

An alternative solution might be to script the Windows Desktop Search. For more information about this feature, visit the following Microsoft Web site:

↑ Back to the top


Keywords: kbentirenet, kbexpertisebeginner, kbtshoot, kberrmsg, kbprogramming, kbautomation, kbexpertiseinter, kbprb, kb

↑ Back to the top

Article Info
Article ID : 920229
Revision : 1
Created on : 1/7/2017
Published on : 2/18/2008
Exists online : False
Views : 103