View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Running macro on multiple files

'As requested...
'--
Sub ProcessAllFiles()
Dim sFile As String
Const sPath As String = "C:\WINDOWS\Temp\"

sFile = Dir(sPath & "*.*")
Do While sFile < ""
MsgBox sFile
' Workbooks.Open (sPath & sFile)
' HELO_Macro
' ActiveWorkbook.Close savechanges:=True
sFile = Dir
Loop
End Sub
;--
Jim Cone


"Matt S"
wrote in message
Jim,
I'm new to macros... can you please paste your code so I can see where
you've changed path to sPath?
Thanks,
Matt



"Jim Cone" wrote:
I changed "path" to sPath and used "C:\WINDOWS\Temp" as the path
and it picked up every file in the folder.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)






"Matt S"
wrote in message
I posted this earlier on an old thread, but I guess it doesn't bump the old
thread for people to see. I hope I'm not breaking any rules or whatever, so
please ignore this post if I am.
Thanks,
Matt

-snip-
"If I step through the code, it just goes right over the While loop,"
-snip-

Sub ProcessAllFiles()
Dim sFile$
Const path = "C:\Temp\Temp1\"
sFile = Dir(path & "*.*")
Do While sFile < ""
Workbooks.Open (path & sFile)
HELO_Macro
ActiveWorkbook.Close savechanges:=True
sFile = Dir
Loop
End Sub