【发布时间】:2016-12-13 11:37:51
【问题描述】:
我在 Excel 文件中有一些数据,我需要与他人分享。 对方对格式有特定要求:文本文件、*.dat 名称、管道分隔等。
所以我创建了一个 VBA 代码,以使用此站点中的示例将数据提取到文本文件中。
目前我的文件未被接受,因为:“它不是 UTF-8 UNIX 格式”。 我从互联网上尝试了多种解决方案,但每次我收到的答案都是“UTF-8 PC 格式”或“Unicode 格式”。
有人可以帮我解决这个问题吗?到目前为止,这是我所拥有的:
'create output (this is from my initial version)
Set Fileout = fso.CreateTextFile(myFile, True, True)
For y = 2 To a
Fileout.WriteLine .Cells(y, 59)
Next y
Fileout.Close
'this is from my second conversion attempt, where I received UTF-8 PC format
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Position = 0
stream.Charset = "UTF-8"
stream.LoadFromFile myFile
'This is my latest try. I found something called "UTF-8 without BOM" on the internet. Still doesn't work.
Set StreamUnixUtf = CreateObject("ADODB.Stream")
StreamUnixUtf.Type = 1
StreamUnixUtf.Mode = 3
StreamUnixUtf.Open
stream.Position = 3
stream.CopyTo StreamUnixUtf
stream.Flush
stream.Close
StreamUnixUtf.SaveToFile myFileUnixUTF, 2
StreamUnixUtf.Close
提前感谢您的帮助。
【问题讨论】: