.LookIn problem 2007

  • Thread starter Thread starter Tim Williams
  • Start date Start date
Application.FileSearch Property is not available in 2007 version. Instead try
using Dir ..or check out help on FileSystemObject...

If you want to filter by xl files then try cmd*.xl*

Sub Macro()
Dim strFile As String, strFolder As String
strFolder = "C:\"
strFile = Dir(strFolder & "\cmd*.*", vbNormal)
Do While strFile <> ""
MsgBox strFile
strFile = Dir
Loop
End Sub
 
This is code from excel help, Office 2007 excel running windows 7 64 bit.

Set fs = Application.FileSearch
With fs
.LookIn = "C:\My Documents"
.FileName = "cmd*.*"
If .Execute > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With


The code produces the error "object doesn't support this action" at "Set
fs = Application.FileSearch." I tried "Dim fs as Application" but got
same error.

My first venture into this so I don't know what is going on.

I want to open every excel program in a particular folder, get stuff
from it etc. and close it.

John
 
Ok, thanks... I got all that. Now another problem.

Dim FileName as string
Dim Wb as Workbook
I get the name of the workbook file in the string then open it with
Set Wb = Applicatin.Workbooks.Open(Filename, , , , "password")

How do I get the workbook to say hidden? I want to get info out of it
but I don't want it to be flashing all over the screen when I open and
access it.

I tried Wb.hide but it said isn't appropriate.

Thanks
JOhn
 
If you're just opening it briefly to extract information:

Application.Screenupdating=false
'open, extract, close
Application.Screenupdating=true

Tim
 
Thanks
John
Tim said:
If you're just opening it briefly to extract information:

Application.Screenupdating=false
'open, extract, close
Application.Screenupdating=true

Tim
 
Back
Top