DBF to CSV Conversion
VBA_93
-
VBA_93 -
VBA_93 -
Hello everyone,
Currently, I'm trying to convert .dbf files into .csv files using an Excel 2010 macro.
Here’s what I’ve done:
So I'm asking for your help!
I forgot to mention a few additional pieces of information:
-My Excel 2010 is in French
-My file with the macro is in the same folder as my .dbf files
Thank you in advance for your responses.
Currently, I'm trying to convert .dbf files into .csv files using an Excel 2010 macro.
Here’s what I’ve done:
Sub ConvertDBF_to_CSV() Dim strDocPath As String Dim strCurrentFile As String Dim Fname As String Dim sFiles Dim x As Integer, y As Integer Application.ScreenUpdating = False x = 0 y = 0 sFiles = Dir(ThisWorkbook.Path & "\*.dbf") 'count the files Do Until sFiles = "" x = x + 1 sFiles = Dir Loop strDocPath = "C:\Users\fg733136\Documents\Projet Horaire PCC\03SABRAQUE corrigé\03SABRAQUE corrigé" 'strCurrentFile = Dir(strDocPath & "*.*") strCurrentFile = Dir(strDocPath & "*.dbf") Do While strCurrentFile <> "" y = y + 1 'display current status on status bar Application.StatusBar = "Converting " & y & " of " & x Workbooks.Open Filename:=strDocPath & strCurrentFile Fname = Left$(strCurrentFile, Len(strCurrentFile) - 4) & ".csv" ActiveWorkbook.SaveAs Filename:=strDocPath & Fname, FileFormat:=6, CreateBackup:=False, local:=True strCurrentFile = Dir Loop Application.StatusBar = False 'release the status bar back to excel Application.ScreenUpdating = True End Sub
EDIT : Added code tags
I run it, but I get no result...So I'm asking for your help!
I forgot to mention a few additional pieces of information:
-My Excel 2010 is in French
-My file with the macro is in the same folder as my .dbf files
Thank you in advance for your responses.
2 answers
-
Hello,
The folder name shouldn't end with "\" right?
If you do some debugging, you'll see that it normally doesn't find any files.
See you later! -
-
I forgot to indicate which line I thought contained an error.
On line 21: strCurrentFile = Dir(strDocPath & "*.dbf")
However, strDocPath = "C:\Users\fg733136\Documents\Projet Horaire PCC\03SABRAQUE corrigé\03SABRAQUE corrigé"
So strCurrentFile = Dir("C:\Users\fg733136\Documents\Projet Horaire PCC\03SABRAQUE corrigé\03SABRAQUE corrigé\*.dbf")
It seems that the underlined \ is missing, I think. -
-
-
-
-