如何在VBA(Exel)中获取文件csv的编码类型 [英] how to get encoding type of a file csv in VBA(Exel)

查看:580
本文介绍了如何在VBA(Exel)中获取文件csv的编码类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些CSV文件,我想在Exel中使用VBA获得其编码类型.

但我做不到.

您能帮我解决这个问题吗?

感谢您的进步.

I have some file CSV and I want to get their encoding type using VBA in Exel.

but I can not do this.

Could you help me resolve this problem?

thanks for advance

推荐答案

对于VB.NET,您可以使用StreamReader类的detectEncodingFromByteOrderMarks参数进行检测.
http://msdn.microsoft.com/zh-CN/library/akzyzwh9%28v = VS.80%29.aspx [ ^ ]

不幸的是,这不适用于VBA/VB6.可能您可以自己读取它的第一个字节,然后使用它来确定编码,从而自行检测到它.
http://codesnipers.com/?q=node/68 [ http://msdn.microsoft.com/en-us/library/314cz14s%28v = VS.85%29.aspx [ ^ ]

祝你好运!
For VB.NET you could use the detectEncodingFromByteOrderMarks parameter of the StreamReader class to detect this.
http://msdn.microsoft.com/en-US/library/akzyzwh9%28v=VS.80%29.aspx[^]

Unfortunately this isn''t available for VBA/VB6. Possibly you could detect it yourself by reading the first bytes from it and use that to determine the encoding.
http://codesnipers.com/?q=node/68[^]


For reading you could use the FileSystemObject that has support for default, ASCII and unicode.
http://msdn.microsoft.com/en-us/library/314cz14s%28v=VS.85%29.aspx[^]

Good luck!


这篇关于如何在VBA(Exel)中获取文件csv的编码类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆