Je souhaite exporter un fichier que j'ai créé dans UTF-8 CSV en utilisant VBA. De la recherche forums, j'ai trouvé le code suivant qui convertit un fichier en UTF-8 (from this thread):Exporter une feuille sous forme de fichier CSV UTF-8 (en utilisant Excel-VBA)
Sub SaveAsUTF8()
Dim fsT, tFileToOpen, tFileToSave As String
tFileToOpen = InputBox("Enter the name and location of the file to convert" & vbCrLf & "With full path and filename ie. C:\MyFolder\ConvertMe.Txt")
tFileToSave = InputBox("Enter the name and location of the file to save" & vbCrLf & "With full path and filename ie. C:\MyFolder\SavedAsUTF8.Txt")
tFileToOpenPath = tFileToOpen
tFileToSavePath = tFileToSave
Set fsT = CreateObject("ADODB.Stream"): 'Create Stream object
fsT.Type = 2: 'Specify stream type – we want To save text/string data.
fsT.Charset = "utf-8": 'Specify charset For the source text data.
fsT.Open: 'Open the stream
fsT.LoadFromFile tFileToOpenPath: 'And write the file to the object stream
fsT.SaveToFile tFileToSavePath, 2: 'Save the data to the named path
End Sub
Cependant, ce code ne convertit un fichier non-UTF-8 en UTF-8. Si je devais enregistrer mon fichier en non-UTF-8 et le convertir en UTF-8, il aurait déjà perdu tous les caractères spéciaux qu'il contenait, rendant ainsi le processus inutile!
Ce que je cherche à faire est d'enregistrer un fichier ouvert en UTF-8 (CSV). Y at-il un moyen de le faire avec VBA?
n.b. J'ai également posé cette question sur le 'ozgrid' forum. Ferme les deux threads ensemble si je trouve une solution.
Mon exemple ici exportera une plage dans Excel en UTF-8 CSV http://stackoverflow.com/questions/12352958/excel-vba-export-to-utf-8/12353832#12353832. Il y a quelques mises à jour, soit convertir http, une chaîne ou le dernier vous permet de spécifier une plage. – user3357963
Ou donnez-nous un coup http://www.mediafire.com/view/?zbngcy2sborbklm – user3357963
Comme j'avais exactement le même problème, j'ai trouvé votre message et après j'ai trouvé la réponse sur un site français! http://geek-mondain.blogspot.fr/2011/09/excel-et-son-incapacite-exporter-des.html Cela a fonctionné parfaitement! –