View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Macro working well in Excel 97 but not in excel 2003

Yes, but which line of code gives the error?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"yvautrin" wrote in message
...
Now, with the macro herebelow, it imports the first file of the defined
folder, and stops with the following error "Run Time error 1004"

Qpplication
defined or object defined error


macro :

Sub Macro1()
'
' Macro1 Macro
' Macro enregistrée le 18/04/05 par bougeard_gregory '
'1- On ouvre les fichiers et les convertits chemin = InputBox("Entrez le
chemin du dossier contenant les fichiers")
yann3 (chemin)
'
End Sub

Sub yann3(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