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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,214,861
Messages
6,121,973
Members
449,059
Latest member
oculus

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