DBF Files to Workbook

acorrea4

New Member
Joined
Nov 2, 2005
Messages
2
I get hundreds of excel DBF Files that I have to open and then resave as Excel Workbooks. I use the exact file name and just change them from DBF to Workbook.

Is there anyway that I can do some automatic save to change all of the files at one time from DBF to Workbooks without haveing to open and resave each file?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Welcome to MrExcel Board!

How about something like this in a standard module:

Code:
Sub saveDBF2XL()
Dim myFile As String
Dim myPath As String

    myPath = "C:\test\"
    myFile = Dir(myPath & "*.dbf")
    If myFile = "" Then Exit Sub

    While myFile <> ""
        Workbooks.Open myPath & myFile
        ActiveWorkbook.SaveAs Left(myFile, Len(myFile) - 4) & ".xls"
        ActiveWorkbook.Close 0
        myFile = Dir
    Wend

End Sub

I tried to get this to work a bit differently, saving an closing at the same time, but it didn't work the way I wanted. This does. Open a blank workbook, and put this code in it like so:

  • How to use the above code:

    Press Alt-F11 to open the VBE.
    Press Control-R to open the Project Explorer.
    Click "Microsoft Excel Objects" for the file you're working on.
    Select Insert, Module from the drop down menus.

    Open the Code pane with F7.
    Paste the above code in.
    Press Alt-Q to close the VBE and return to Excel

Change the myPath variable in the code to reflect the path you want to use, and you should be all set.

Hope that helps!
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

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