Converting all EXP files in a folder to Excel files.

Anusuya12

New Member
Joined
Feb 27, 2011
Messages
27
Hi,

I have a set of files stored in a folder with .exp. I need a macro which can convert the .exp files to .xls files. I want the name of the file to remain the same, only the extension to be changed.

Appreciate your help on this.

Thanks.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Do you just want the files to be renamed? If so use the Name statement in a Dir loop.

Otherwise, what is the data format of these .exp files? Are they Excel workbooks/CSV files which Excel can open using File - Open? If so, post the code generated by the macro recorder of you opening/importing one of the files.
 
Upvote 0
Hi,

I just need the file to be renamed. I not aware of how to use DIR code. Can you let me know that.

Thanks.
 
Upvote 0
Try this. You need to modify the line where shown to specify the folder containing the .exp files.
Code:
Public Sub Loop_Rename_Files_in_Folder()

    Dim folder As String
    Dim filename As String
   
    folder = "C:\Path to\your\folder\"               'MODIFY THIS LINE - FOLDER CONTAINING FILES TO BE RENAMED
    
    If Right(folder, 1) <> "\" Then folder = folder & "\"
    filename = Dir(folder & "*.exp")
    Do While filename <> vbNullString
        Name folder & filename As folder & Left(filename, InStrRev(filename, ".")) & "xls"
        filename = Dir
    Loop

End Sub
 
Upvote 0
Hi there,

It works fine. Similar to this I need a code which can renames the files with unknown extension.
These files are actually transfered from another application. So it comes with number as extension.
say for example R301.123; R301.235
Now I need to rename this file as R301.123.xls;R301.235.xls
Thanks.
 
Upvote 0
Code:
Public Sub Loop_Rename_Files_in_Folder2()

    Dim folder As String
    Dim filename As String
   
    folder = "C:\Path to\your\folder\"               'MODIFY THIS LINE - FOLDER CONTAINING FILES TO BE RENAMED
    
    If Right(folder, 1) <> "\" Then folder = folder & "\"
    filename = Dir(folder & "*.*")
    Do While filename <> vbNullString
        If Right(filename, 4) <> ".xls" Then Name folder & filename As folder & filename & ".xls"
        filename = Dir
    Loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,629
Messages
6,173,445
Members
452,514
Latest member
cjkelly15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top