Help in running this script lower than Excel 2000

M

M

I have the ff script which ran ok in Excel 2000, but does
not work at a lower version, particularly the part where
it searched for the filename. Can someone please help
me, convert it or totally revise the script?
Thanks

rnum = 1
With Application.FileSearch
.NewSearch
.LookIn = "Z:\GT05\WBG\" & Left(code, 3) & "\"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
.Filename = "*-DeptConsol.xls"
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Set mybook = Workbooks.Open(.FoundFiles
(i))
Set sourceRange = mybook.Worksheets
(1).Range("A1:p170")
SourceRcount = sourceRange.Rows.Count
Set destrange = basebook.Worksheets
(1).Cells(rnum, 1)
basebook.Worksheets(1).Cells
(rnum, "Q").Value = mybook.Name
With sourceRange
Set destrange = basebook.Worksheets
(1).Cells(rnum, "A"). _
Resize
(.Rows.Count, .Columns.Count)
End With
destrange.Value = sourceRange.Value
 
T

Tom Ogilvy

If using xl97 then

Try just changing
.Filename = "*-DeptConsol.xls"

to

.Filename = "-DeptConsol.xls"

if using xl95 or earlier, then you will have to use Dir()
 

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