Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Insert text into filename

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Insert text into filename

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Insert text into filename

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert filename via a browse to cell Rookie_User Excel Discussion (Misc queries) 2 February 25th 08 09:23 PM
How do I insert the filename of the worksheet into a cell? joeker Excel Discussion (Misc queries) 2 April 10th 06 01:33 PM
How do I insert a partial filename? Admin Excel Discussion (Misc queries) 1 December 1st 05 01:49 AM
How can I insert the contents of a cell as a filename? Tim Richards[_3_] Excel Programming 2 February 21st 05 07:45 PM
Insert value of a cell as a filename Ralph Howarth Excel Worksheet Functions 0 January 18th 05 12:03 AM


All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"