Txt delimiter et excel

scromania Messages postés 452 Date d'inscription dimanche 20 août 2006 Statut Membre Dernière intervention 11 janvier 2013 - 20 mai 2009 à 08:14
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 - 20 mai 2009 à 10:32
bonjour tout le monde,

je cherche a ouvrir un fichier txt et l'enregistrer en xls
je ne parvient pas à delimité.

j'ai trouvé cette exemple ,mais il y a des erreur
Dim

FSO : FSO = CreateObject(
"Scripting.FileSystemObject")

Dim waExcel : waExcel = CreateObject(
"Excel.Application")
'Ouverture d'ExcelStrPath =

"C:\Donnees\Rapport"
'Chemin d'accŠs du fichier

If Right(StrPath, 1) <>
""
Then StrPath = StrPath &
""
'Ajoute \ … la fin s'il y en a pasStrFich =

"Igli07_aout.txt"
'Nom du fichier

If FSO.FileExists(StrPath & StrFich)
Then
'Existance du fichierwaExcel.Visible =

False
'Rendre invisible Excel

'Importe le fichier texte vers une feuille Excel de fa‡on Largeur fixe avec d‚limiteur : Tabulation et SpacewaExcel.Workbooks.OpenText(StrPath & StrFich, , , 2, , ,

True, , ,
True)

'Sauvegarde la feuiller importer vers le chemin d'accŠs de d‚part en motifiant l'extension et en mode partag‚ pour ‚viter des erreurswaExcel.Workbooks(StrFich).SaveAs(StrPath & Left(StrFich, Len(StrFich) - 4) &

".xls", , , , , , 2)

End
If

'Fermeture d'ExcelwaExcel.Application.Quit()

quelqu'un peut m'aider s'il vous plait

Merci
cyrille

2 réponses

cs_loulou69 Messages postés 672 Date d'inscription mercredi 22 janvier 2003 Statut Membre Dernière intervention 2 juin 2016 1
20 mai 2009 à 09:18
bonjour

Où est le problème?

Regarde tous les paramètres de OpenText et SaveAs sur l'aide d'Excel
Ta réponse se trouve dans les paramètres
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
20 mai 2009 à 10:32
StrPath = "C:\Donnees\Rapport"
If Right(StrPath, 1) <> "" Then StrPath = StrPath & ""

pourquoi le "" ne serait il pas présent ?


demarre l'enregistrement de macro, sous excel
ouvre ton fichier et regarde le code généré
0
Rejoignez-nous