View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default opening worksheets

Dim sPath as String
Dim sName as String
Dim wkbk as Workbook
sPath = "C:\MyFolder\"
sName = dir(sPath & "*.xls")
do while sName < ""
set wkbk = Workbooks(sName)
msgbox wkbk.Name
' process the file
wkbk.Close SaveChanges:=False ' or True
sName = Dir()
Loop

--
Regards,
Tom Ogilvy

"platinum_eye200 " wrote in
message ...
I wish to open all the worksheets in a particular folder. Then i want
to be able to extract information from each worksheet, and its
filename, without entering a filename. Is this possible? How do I do
it?

the reason I want to is quite simple. I have hundreds of worksheets
with inconsistant names, and I want to apply a macro to each, and save
time by having the macro open, extract, and close the lot.

thanks for your help,

martin


---
Message posted from http://www.ExcelForum.com/