Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a folder full of files that I open, modify and then save to
another folder, all done by a macro. I'd like the macro to rename the files, taking the old name and adding Mod to the name. So if the old file is "xyz.xls" I'd like it to be "xyz Mod.xls". I appreciate your help. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim SaveName As String SaveName = SaveMod(ThisWorkbook) ' Change the 'Thisworkbook' to whatever workbook you want End Sub Public Function SaveMod(Workbook As Workbook) As String Dim strName As String, strExt As String, strpath With Workbook strName = .Name strpath = .Path If Right(strpath, 1) < "\" Then strpath = strpath & "\" End If strExt = Right(strName, 4) strName = Left(strName, Len(strName) - 4) strName = strName & "Mod" & strExt SaveMod = strpath & strName .SaveCopyAs SaveMod End With End Function "davegb" wrote: I have a folder full of files that I open, modify and then save to another folder, all done by a macro. I'd like the macro to rename the files, taking the old name and adding Mod to the name. So if the old file is "xyz.xls" I'd like it to be "xyz Mod.xls". I appreciate your help. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks!
Hayeso wrote: Sub test() Dim SaveName As String SaveName = SaveMod(ThisWorkbook) ' Change the 'Thisworkbook' to whatever workbook you want End Sub Public Function SaveMod(Workbook As Workbook) As String Dim strName As String, strExt As String, strpath With Workbook strName = .Name strpath = .Path If Right(strpath, 1) < "\" Then strpath = strpath & "\" End If strExt = Right(strName, 4) strName = Left(strName, Len(strName) - 4) strName = strName & "Mod" & strExt SaveMod = strpath & strName .SaveCopyAs SaveMod End With End Function "davegb" wrote: I have a folder full of files that I open, modify and then save to another folder, all done by a macro. I'd like the macro to rename the files, taking the old name and adding Mod to the name. So if the old file is "xyz.xls" I'd like it to be "xyz Mod.xls". I appreciate your help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Insert filename via a browse to cell | Excel Discussion (Misc queries) | |||
How do I insert the filename of the worksheet into a cell? | Excel Discussion (Misc queries) | |||
How do I insert a partial filename? | Excel Discussion (Misc queries) | |||
How can I insert the contents of a cell as a filename? | Excel Programming | |||
Insert value of a cell as a filename | Excel Worksheet Functions |