Je sauvegarde des fichiers excel en format texte, mais j'aurais besoin qu'ils soient au format utf-8.
C'est possible directement avec VBA ou VB de preciser cela ?
pour le moment je suis obligé de tout me refader avec notepad ...
Je sauvegarde des fichiers excel en format texte, mais j'aurais besoin qu'ils soient au format utf-8.
C'est possible directement avec VBA ou VB de preciser cela ?
pour le moment je suis obligé de tout me refader avec notepad ...
Ma page Developpez - Mon Blog Developpez
Président du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts)
Deux règles du succès: 1) Ne communiquez jamais à quelqu'un tout votre savoir...
Votre post est résolu ? Alors n'oubliez pas le Tag![]()
Venez sur le Chat de Développez !
Trouvé sur un autre forum (-> désolé!)
En espérant que ça t'aidera...
1. The old visual basic file commands shouldn't be used. If I remember correctly, Microsoft didn't even provide documentation for those command in VB6. They want you to use FSO or ADODB
2. Unicode is a collection of character sets (e.g. UTF-16, UTF-8). Each encoding will produce a different file (i.e. size and contents)
3. StrConv(strText, vbUnicode) produces UTF-16 (the default Windows Unicode format) not UTF-8
4. Set objTextStream = objFSO.CreateTextFile(strFile, , True) outputs as UTF-16 not UTF-8
There's only one way to do what your asking. Use a stream.
For example ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Private Sub CreateFile(ByVal pstrFile As String, ByVal pstrData As String) Dim objStream As Object 'Create the stream Set objStream = CreateObject("ADODB.Stream") 'Initialize the stream objStream.Open 'Reset the position and indicate the charactor encoding objStream.Position = 0 objStream.Charset = "UTF-8" 'Write to the steam objStream.WriteText pstrData 'Save the stream to a file objStream.SaveToFile pstrFile End Sub
Partager