XL 2021 Creation de fichier txt

  • Initiateur de la discussion Initiateur de la discussion Hieu
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Hieu

XLDnaute Impliqué
Bonjour à tous,

voilà, je souhaite écrire un fichier txt, sous VBa; ca, j'y arrive. Après, le fichier sort au format Windows; je souhaiterai qu'il sorte au format unix.

Et en complément, si quelqu'un sait me dire à quoi correspond les mots clés "FreeFile" et "Output".
J'ai piqué ses lignes, je ne sais plus où, ca fonctionne, mais je n'sais pas c'que j'utilise ^^

Merci par avance;

Code:
Sub ecriture(nom_dat)
titre = "toto.txt"
fic = nom_dat
f = FreeFile
Open fic For Output As #f
Print #f, "hello"
Close #f
End Sub
 
Bonjour à tous,

voilà, je souhaite écrire un fichier txt, sous VBa; ca, j'y arrive. Après, le fichier sort au format Windows; je souhaiterai qu'il sorte au format unix.

Et en complément, si quelqu'un sait me dire à quoi correspond les mots clés "FreeFile" et "Output".
J'ai piqué ses lignes, je ne sais plus où, ca fonctionne, mais je n'sais pas c'que j'utilise ^^

Merci par avance;

Code:
Sub ecriture(nom_dat)
titre = "toto.txt"
fic = nom_dat
f = FreeFile
Open fic For Output As #f
Print #f, "hello"
Close #f
End Sub
Bonjour Hieu,
pour FreeFile une simple recherche avec le navigateur 😉
https://learn.microsoft.com/fr-fr/o...ference/user-interface-help/freefile-function
Et pour Open Output : Ouvrir en écriture (Input : en Lecture)
 
Salut,
Pour écrire en Unix (Ansi) :
VB:
Private Declare PtrSafe Function CharToOem Lib "user32" Alias "CharToOemA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Private Declare PtrSafe Function OemToChar Lib "user32" Alias "OemToCharA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Sub Ecriture()
Dim F As Integer, Txt
    F = FreeFile
    Open ThisWorkbook.Path & "\toto.txt" For Output As #F
        Txt = "hello François, j'étais bien içi"
        OemToChar Txt, Txt
        Print #F, Txt
        Txt = "C'est la fête"
        OemToChar Txt, Txt
        Print #F, Txt
    Close #F
End Sub
 
Salut,
Pour écrire en Unix (Ansi) :
VB:
Private Declare PtrSafe Function CharToOem Lib "user32" Alias "CharToOemA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Private Declare PtrSafe Function OemToChar Lib "user32" Alias "OemToCharA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Sub Ecriture()
Dim F As Integer, Txt
    F = FreeFile
    Open ThisWorkbook.Path & "\toto.txt" For Output As #F
        Txt = "hello François, j'étais bien içi"
        OemToChar Txt, Txt
        Print #F, Txt
        Txt = "C'est la fête"
        OemToChar Txt, Txt
        Print #F, Txt
    Close #F
End Sub
oki, faut faire une commande apres chaque ligne...
Merci !
 
oki, faut faire une commande apres chaque ligne...
Pas obligé on peut écrire un bloc :
VB:
Private Declare PtrSafe Function CharToOem Lib "user32" Alias "CharToOemA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
Private Declare PtrSafe Function OemToChar Lib "user32" Alias "OemToCharA" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long

Sub Ecriture()
Dim F As Integer, Txt
    F = FreeFile
    Open ThisWorkbook.Path & "\toto.txt" For Output As #F
        Txt = "hello François, j'étais bien içi" & vbCrLf _
            & "C'est la fête" & vbCrLf _
            & "3ème ligne"
        OemToChar Txt, Txt
        Print #F, Txt
    Close #F
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
15
Affichages
785
Réponses
2
Affichages
432
Réponses
2
Affichages
1 K
  • Question Question
XL 2013 VB Macro
Réponses
8
Affichages
861
Retour