Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have a really simple need: some code to open all xls files in a specified directory and then save the files with a modified name (e.g. just add "_fm" to filename)to a new subdir. In between the open and save I will insert some code to do some simple formatting but really would appreciate some help in opening a bunch of files and then saving them. Thanks James |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
dim spath1 as string, spath2 as string, fname as string
Dim fname1 as string, wkbk as workbook spath1 = "C:\Myfiles\" sPath2 = "C:\MyfilesNew\" fname = dir(sPath1 & "*.xls") do while fname < "" set wkbk = workbooks.Open(fname) ' modify workbook, next line is an example wkbk.Worksheets(1).Range("A1").Numberformat = "#,##0.0" ' no build the new name fname1 = wkbk.name fname1 = left(fName1,len(fname1)-4) fname1 = fname1 & "_fm.xls" wkbk.SaveAs sPath2 & fname1 wkbk.close SaveChanges:=False fName = dir() Loop code is untested and may contain typos. -- Regards, Tom Ogilvy "James" wrote in message om... Hi I have a really simple need: some code to open all xls files in a specified directory and then save the files with a modified name (e.g. just add "_fm" to filename)to a new subdir. In between the open and save I will insert some code to do some simple formatting but really would appreciate some help in opening a bunch of files and then saving them. Thanks James |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
whenever open or save it is very slow to open | Excel Discussion (Misc queries) | |||
run batch job from each row - how to insert run batch function per row? | Excel Discussion (Misc queries) | |||
batch file to open multiple worksheets | Excel Discussion (Misc queries) | |||
save prompt for user exit, but no save prompt for batch import? | Excel Discussion (Misc queries) | |||
How can I batch open a txt file in excel 2003 and save back as a . | Excel Discussion (Misc queries) |