我希望我的所有文件都保存在Unicode或UTF-8格式,而不是ANSI。
代码如下:
Sub cvelle()
Dim iRow As Long
Dim iFile As Integer
Dim sPath As String
Dim sFile As String
For iRow = 1 To Cells(Rows.Count, "B").End(xlUp).Row
iFile = FreeFile
With Rows(iRow)
sPath = "E:\" & .Range("B1").Value & "\"
If Len(Dir(sPath, vbDirectory)) = 0 Then MkDir sPath
sFile = .Range("D1").Value & ".txt"
Open sPath & sFile For Output As #iFile
Print #iFile, .Range("E1").Value
Close #iFile
End With
Next iRow
End Sub
现在,我认为只要插入下面的代码就足够了。
sFile = .Range("D1").Value & ".txt",FileFormat:= _xlUnicodeText
但它给了我一个错误。
5条答案
按热度按时间c90pui9n1#
我知道如何创建一个未编码的txt文件。也许你可以尝试读取数据到变量〉创建一个未编码的txt〉写入数据到txt〉保存txt
46scxncf2#
fiei3ece3#
我个人在工作中使用它,因为一些pl报告有一大堆格式,为了进行调整,你需要它。这里是一个函数,用于读取
oyjwcjzk4#
希望这可以保存一些时间:
ijxebb2r5#
我没有输入一堆代码,而是找到了使用Unicode作为默认编码的方法:
感谢所有人!