[XL-2010][Problème Migration 2007 à 2010 Macro VBA] Exporter fichier Texte

Bonjour !

j'avais une macro qui fonctionnait à la perfection sous 2007 ,

J'ai du migrer sur 2010 et j'ai ouvert le fichier excel et j'ai un message d'erreur :

"Chemin d'accès introuvable"

Ligne en évidence : Open OutputPath & BaseFileName & (X - StartColumn) & ".mac" For Output As #FF

voici le code :

Sub MakeTextFiles()
  Dim X As Long, Z As Long, FF As Long, TextOut As String
  Const OutputPath As String = "C:\Program Files\"   '<==Note the trailing backslash
  Const BaseFileName As String = "fichier_export"
  Const StartColumn As Long = 1   'Assumed Column B
  Const StartRow As Long = 1      'Assumed Row 3
  For X = StartColumn + 1 To StartColumn + 1
    TextOut = ""
    For Z = StartRow To StartRow + 3250
      TextOut = TextOut & Cells(Z, StartColumn).Value & "" & Cells(Z, X).Value & vbNewLine
    Next
    FF = FreeFile
              Open OutputPath & BaseFileName & (X - StartColumn) & ".mac" For Output As #FF
    Print #FF, TextOut
    Close #FF
    MsgBox "OK à jour"

  Next
End Sub
Rechercher des sujets similaires à "2010 probleme migration 2007 macro vba exporter fichier texte"