View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
voodooJoe voodooJoe is offline
external usenet poster
 
Posts: 43
Default Opening worbooks with a variable file name.

not sure how you're doing the filesearch - but if using the filesearch
method (of file scripting object) then use
"foundfiles(i)" and the workbooks.open method

- voodooJoe

Sub ff()

Set fs = Application.FileSearch
With fs
.LookIn = "C:\"
.Filename = "*.xls"
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
Debug.Print .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub


"ibbm" wrote in message
...
I am tring to open each workbook found in a filesearch, extract some info
and
then close the workbook. I don't know the name of the filepath as it is a
variable from the filesearch. How do I do this. Thanks in advance.