Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello
have a folder with several files with different extensions. I want to change exensions of ".cnf.xml" files to ".xls". I want to do this in excel macro as I need to work on these files then. Is there any way to achieve this? Thank you Regards, prm |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Change folder name as required. Sub changeToXML() Set fs = CreateObject("Scripting.FileSystemObject") Folder = "c:\temp" FName = Dir(Folder & "\" & "*.XML") Do While FName < "" OldName = Folder & "\" & FName 'take old anem remove extension NewName = Left(OldName, InStrRev(OldName, ".")) 'add xls NewName = NewName & "xls" fs.MoveFile OlName, NewName FName = Dir() Loop End Sub -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=151886 Microsoft Office Help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the below
Sub Macro() Dim strFile As String, strFolder As String strFolder = "c:\" strFile = Dir(strFolder & "*.cnf.xml", vbNormal) Do While strFile < "" Name strFolder & strFile As strFolder & Replace(strFile, ".cnf.xml", ".xls") strFile = Dir Loop End Sub If this post helps click Yes --------------- Jacob Skaria "Pawan" wrote: Hello have a folder with several files with different extensions. I want to change exensions of ".cnf.xml" files to ".xls". I want to do this in excel macro as I need to work on these files then. Is there any way to achieve this? Thank you Regards, prm |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Jacob.. It worked! :)
"Jacob Skaria" wrote: Try the below Sub Macro() Dim strFile As String, strFolder As String strFolder = "c:\" strFile = Dir(strFolder & "*.cnf.xml", vbNormal) Do While strFile < "" Name strFolder & strFile As strFolder & Replace(strFile, ".cnf.xml", ".xls") strFile = Dir Loop End Sub If this post helps click Yes --------------- Jacob Skaria "Pawan" wrote: Hello have a folder with several files with different extensions. I want to change exensions of ".cnf.xml" files to ".xls". I want to do this in excel macro as I need to work on these files then. Is there any way to achieve this? Thank you Regards, prm |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
List Filenames from Folder | Excel Programming | |||
getting filenames from a user selected folder | Excel Programming | |||
Look for a string in filenames in a folder? | Excel Programming | |||
Help with a Macro to list all filenames and mod dates in a folder | Excel Programming | |||
Folder and filenames? | Excel Programming |