View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Matt S Matt S is offline
external usenet poster
 
Posts: 112
Default Running macro on multiple files

Thank you Jim! This worked perfectly. How do I force it to save the new
files into a new folder and convert the files to excel workbooks? Seems when
it saves the files now, they automatically save as 1-sheet files.

Thanks!
Matt

"Jim Cone" wrote:

'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