Run-Time Error 5111

P

petecjr

I have been using the VBA subroutine "BATCH" below in WORD 2003 to perform
any desired series of actions on all of the files in a given folder. I
recently upgraded to Office 2007 and when I run the subroutine I receive the
Run-Time Error 5111 "This command ("With Application.FileSearch") is not
available on this platform. Is there a way to do this in VBA for Office 2007.
Please help. Thanks.

Sub BATCH()
'This routine is used to perform actions on all files in a folder.

Dim LISTNAME(500)

With Application.FileSearch
..FileName = "*.*"
..LookIn = CurDir
If .Execute(msoFileFindSortbyFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
For I = 1 To .FoundFiles.Count
Documents.Open FileName:=.FoundFiles(I) '(Use this if needed)

'Insert actions to be performed.

ActiveDocument.SAVE ' (Use this if needed)
ActiveWindow.Close ' (Use this if needed)
Next I
End If


End With

End Sub
 

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