Salut,
ceci devrait aller -
)
'======================
'Importer dans un classeur un fichier texte de grande taille
'(ajoute des feuilles chaque fois que le fichier importé
'remplit 65000 lignes)
'Sören Lindqvist, mpep
Sub ImportLargefile()
'Dimension Variables
Dim ResultStr As String
Dim FileName As String
Dim FileNum As Integer
Dim Counter As Double
FileName = 'C:\\Temp\\yourfile.txt'
'If you want an inputbox use the below:
'InputBox('Write name of file and path')
If FileName = '' Then End
FileNum = FreeFile()
Open FileName For Input As #FileNum
Application.ScreenUpdating = False
Workbooks.Add template:=xlWorksheet
Counter = 1
Do While Seek(FileNum) <= LOF(FileNum)
Application.StatusBar = 'Importerar Rad ' & _
Counter & ' Från TextFil ' & FileName
Line Input #FileNum, ResultStr
If Left(ResultStr, 1) = '=' Then
ActiveCell.Value = ''' & ResultStr
Else
ActiveCell.Value = ResultStr
End If
If ActiveCell.Row = 65500 Then
' I'll need some space below
'If file is larger than (65500.st)
ActiveWorkbook.Sheets.Add
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1
Loop
Close
Application.StatusBar = False
End Sub
'======================
===== fin de copie =====