Application.FileSearch in Word2007 VBA

N

Nancy22

This bit of code is in a macro that used to run fine under Word2003:

With Application.FileSearch
.NewSearch
.LookIn = "c:\My Documents\myfile"
.SearchSubFolders = False
.FileName = lookFor

Now under Word2007, when I try to run the same macro, it stops at that line
and I get the error message "Run-time error 5111: This command is not
available on this platform."

What does this mean and how can I fix my old macro so that it works?
 
J

Jay Freedman

This bit of code is in a macro that used to run fine under Word2003:

With Application.FileSearch
.NewSearch
.LookIn = "c:\My Documents\myfile"
.SearchSubFolders = False
.FileName = lookFor

Now under Word2007, when I try to run the same macro, it stops at that line
and I get the error message "Run-time error 5111: This command is not
available on this platform."

What does this mean and how can I fix my old macro so that it works?

It means that the FileSearch object has been removed from VBA in Office 2007
programs.

Depending on exactly what purpose you're using FileSearch for, you can use the
VBA-native Dir function or the Windows Scripting Runtime object
FileSystemObject.

There's some sample code at
http://www.eggheadcafe.com/software/aspnet/31624256/excel-2007-filesearch.aspx.
 

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