使用VBA,字符集UTF-8将Excel文件导出为文本

时间:2019-06-18 12:12:16

标签: excel vba

有人知道如何保存为UTF-8格式吗?

问题是我有斯堪的纳维亚字母,但ANSI不支持这些字母。

Sub savetoText1()
    Dim FileToSave As String, lineText As String
    Dim myrng As Range, i, j

    FileToSave = ThisWorkbook.Path & "\test" & Format(Now, "yyyymmdd-hhmmss") & ".xml"

    Open FileToSave For Output As #1

    Set myrng = Range("xml!$A:A")


For i = 1 To myrng.Rows.Count
    For j = 1 To myrng.Columns.Count

    If lineText = IIf(j = 1, "", lineText & " ") & myrng.Cells(i, j) Then
    Close #1
    Exit Sub
    End If

        lineText = IIf(j = 1, "", lineText & " ") & myrng.Cells(i, j)
    Next j
    Print #1, lineText
Next i
Close #1
End Sub

0 个答案:

没有答案