View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_19_] Stuart[_19_] is offline
external usenet poster
 
Posts: 7
Default Inconsistent error




The following block of code works absolutly fine when in a workbook by
itself, however, when it is part of the module it is intened for it creates
an error on the execute line!

"runtime error 5"
"Invalid procedure call"

I don't know why this is happening and would like an explination or a
pointer to why this maybe happening

If I remove everything in the line beyond Ececute it works fine.

When the error is occuring hovering the mouse over msoSortBy....... gives a
value of Empty. This should not be the case as the code works fine in
another workbook!



With Application.FileSearch
.LookIn = "C:\shop\hist\data"
.SearchSubFolders = False
.FileName = "reple*.xls"
.Execute SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending
temp = .FoundFiles(.FoundFiles.Count)
End With