Bonjour,
Avec le code vbs ci-dessous, je souhaite que toutes les cellules de ma feuille excel soit au format texte.
Mais lors de la lecture du fichier toto.txt avec la méthode OpenText, Excel ne tient pas compte des indications que je lui donne.
J'utilise Excel 2003.
Est-ce que quelqu'un peut m'aider ?
test.vbs
toto.txtCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Dim strFileName, objExcel, fileNameXls, strDataTypes Const xlTextFormat = 2 strFileName="C:\dev\toto.txt" fileNameXls = "C:\dev\toto2.xls" strDataTypes = Array(Array(1, xlTextFormat),Array(2, xlTextFormat), Array(3, _ xlTextFormat), Array(4, xlTextFormat), Array(5, xlTextFormat), Array(6, _ xlTextFormat), Array(7, xlTextFormat), Array(8, xlTextFormat), Array(9, _ xlTextFormat), Array(10, xlTextFormat)) Set objExcel = CreateObject("Excel.Application") objExcel.Application.DisplayAlerts = False objExcel.Workbooks.OpenText strFileName, , , 1, -4142, , , , , , True, "|", strDataTypes objExcel.ActiveWorkbook.SaveAs fileNameXls objExcel.ActiveWorkbook.Saved = True objExcel.ActiveWorkbook.Close objExcel.Application.Quit Set objExcel = Nothing
2007-1-3|01-01-2007|2725|Rob, E.(Eveline)|10-12-1969|37|1|24-11-2004|05-01-2007|Overige reden
2007-18-3|01-01-2007|3178|Kroonenberg, J.(Johannes)|09-10-1970|36|2|24-11-2004|05-01-2007|Overige reden
2007-21-3|01-01-2007|3182|Kuipers, J.J.A.(John)|27-09-1985|21|3|24-11-2004|05-01-2007|Verhuizing naar anderegemeente / wgr
2007-1-63|01-01-2007|2755|Doorgeest, M.(Marianne)|12-04-1948|59|4|30-06-2004|11-01-2007|Overige reden
2007-1-13|01-01-2007|3072|Brandes, A.F.K.(Lex)|07-02-1961|46|5|23-08-2004|11-01-2007|Overige reden