|
|
|
|
Bonjour,
Salut tout le monde!
J'aimerai ouvrir un fichier txt en xls.
Le fichier en .txt se présente sous cette forme : "nomSite"_Data10min_"date"
Le fichier .txt => nomSite_Data10min_date.txt => à 2 variables avec comme 1° variable "nomSite" est comme 2° variable "Date"
Je dois pouvoir rentrer le nom du site
et la date est celle du systéme sous la forme aaaa-mm-jj
J'ai écrit qqlignes de la macro pour ouvrir le fichier .txt
Je ne sais pas comment l'ouvrir en .xls
Sub ouvrirfichier()
Dim reponse As String
Dim Repertoire As String
reponse = InputBox("Donner le nom du site", "Nom du site")
If NomSite = "" Then End
MaDate = Format(Date, "yyyy-mm-dd")
Repertoire = "C:\Documents and Settings\HOURCADE\Bureau\JDH"
Workbooks.OpenText Filename:=Repertoire & "\" & reponse & "_Data10min_" & MaDate & ".txt"
End Sub
J'ai compiler la macro, elle me demande bien le nom du site mais elle n'ouvre pas le fichier :/
MErci par avance des futurs aides
JD
Configuration: Windows XP Internet Explorer 7.0
RE tout le monde,
|
Bonsoir,
|
Re,
Workbooks.OpenText Filename:="D:\test\essai.txt", Origin:=xlMSDOS, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, Comma:=False, _
Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3 _
, 1), Array(4, 1), Array(5, 1), Array(6, 1)), TrailingMinusNumbers:=True
Il suffit de remplacer Filename:="D:\test\essai.txt" par Filename:=Repertoire & "\" & reponse & "_Data10min_" & MaDate & ".txt" Voila, normalement ça devrait marcher. |
RE, les gens
Sub ouvrirfichier()
Dim reponse As String
Dim Repertoire As String
Dim MaDate As String
reponse = InputBox("Donner le nom du site", "Nom du site")
If reponse = "" Then Exit Sub
MaDate = Format(Date, "yyyy-mm-dd")
Repertoire = "C:\Documents and Settings\HOURCADE\Bureau\JDH"
'Workbooks.OpenText Filename:=Repertoire & "\" & reponse & "_Data10min_" & MaDate & ".txt"
Workbooks.OpenText Filename:=Repertoire & "\" & reponse & "_Data10min_" & MaDate & ".txt" _
, Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1)), TrailingMinusNumbers:=True
End Sub
Quand je compile il fait toujours erreur 1004 pour dire qu'il ne trouve pas mon fichier 'site1_Data10min_2008-05-02.txt' si la variable reponse=site1 Aussi même avec ce simple code :
Sub ouvrirfichier()
Dim reponse As String
Dim Repertoire As String
Dim MaDate as String
reponse = InputBox("Donner le nom du site", "Nom du site")
If reponse = "" Then Exit Sub
MaDate = Format(Date, "yyyy-mm-dd")
Repertoire = "C:\Documents and Settings\HOURCADE\Bureau\JDH"
Workbooks.OpenText Filename:=Repertoire & "\" & reponse & "_Data10min_" & MaDate & ".txt"
End Sub
il me fait la même erreur... Je ne comprend pas j'ai regardé au moins 4 fois l'orthographe et c'est exactement pareil... SVP aidez-moi J'utilise Miscrosoft Excel 2003 voila^^ MERci!! |
Bonjour,
|
OK Super J'ai comprit mon erreur :
|