DBF to CSV Conversion

Hello everyone,
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

  1. 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!
    0
    1. Hello Zoul67,
      Thank you for your response. I have removed it, but I still have no results...
      0
      1. 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.
        0
      2. How do you do the _ \underlined and also modify it at the level of strDocPath?
        0
      3. It shouldn't be underlined in VBA, but rather written
        strDocPath = "C:\Users\fg733136\Documents\Projet Horaire PCC\03SABRAQUE corrigé\03SABRAQUE corrigé\"

        (it ends with \ and not with corrigé)
        0
      4. Ok, that's good, it's working well, thank you!!!! So I wanted to know if what I wrote afterwards was useful or not for creating the Excel screen interface to display the status of the conversion.
        0
      5. Thank you for trying to be clearer.
        0