View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Hari[_3_] Hari[_3_] is offline
external usenet poster
 
Posts: 157
Default Opening excel files automatically

Hi William,

Thanx a lot for the code.

When I run it my excel hangs and even after waiting for 5 or 6 minutes there
is no result. I pressed Ctrl+break to get out of the code. Im using Excel
2002 and Win 2000.

When I enter the code after stopping it the line "For i = 1 To
..FoundFiles.Count" is highlighted in yellow.

Please tell me how to overcome the same.

Regards,
Hari
India


"William" wrote in message
...
Hi Hari

Sub OpenWorkbooksInLocation()
Application.ScreenUpdating = False
Dim i as integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\CCAPPS\ttlview\TMP"
.SearchSubFolders = False
.FileName = "*.xls"
.Execute
For i = 1 To .FoundFiles.Count
Set wb = Workbooks.Open(FileName:=.FoundFiles(i))
'Macro code for each workbook here
wb.Save
wb.Close
Next i
End With
Application.ScreenUpdating = True
End Sub


--
XL2002
Regards

William



"Hari" wrote in message
...
| Hi,
|
| I have a folder "C:\CCAPPS\ttlview\TMP" and I want to open all the excel
| files in this automatically. ( there are around 20 to 25 files normally

in
| this folder)
|
| Once opened I will be running macros which will be collating data from
these
| files and doing some further operations. (I learned those macros from

the
| help of Newsgroups only).
|
| Please tell me if this is possible.
|
| Regards,
| Hari
| India
|
|