Macro working well in Excel 97 but not in excel 2003
Hi Bob,
I did the suggested changes, and now I got an error message "400"
here is the macro including the chages :
Sub Macro1()
'
'chemin = InputBox("Entrez le chemin du dossier contenant les fichiers")
macro2 (chemin)
'
End Sub
Sub macro2(chemin As String)
'
' yann3 Macro
'
'
Dim cpt As Integer
Dim nbFichier As Integer
Dim numLigneConcatene As Integer
nbFichier = 0
numLigneConcatene = 0
chemin = InputBox("Entrez le chemin du dossier contenant les fichiers")
ChDir chemin
Fichier = Dir(chemin)
While Fichier < ""
Workbooks.OpenText Filename:=Fichier, Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=True, _
Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), Array( _
3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1))
nbFichier = nbFichier + 1
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Rows("1:1").Select
Selection.Delete Shift:=xlUp
If numLigneConcatene < 0 Then
Rows("1:1").Select
Selection.Delete Shift:=xlUp
End If
cpt = 1
Range("G1").Select
Do While (ActiveCell.Text < "")
Cells(cpt, 8).Value = ActiveWorkbook.Name
cpt = cpt + 1
Cells(cpt, 7).Select
Loop
ActiveWorkbook.Save
'passe au fichier suivant
Fichier = Dir
Wend
'on copie les donnees dans un seul fichier
Shell ("command.com /C copy " + chemin + "*.txt" + chemin +
"monfichier.txt")
End Sub
thanks for your help
Yann
|