导入文件并将字符集更改为UTF-8

时间:2019-02-06 09:25:53

标签: excel vba unicode character-encoding

我需要一些导入文件的帮助。我已经导出了一个包含俄语文本的.dpl文件,默认情况下未显示该文件。它显示随机字符,如以下示例所示。

lt:3 LANG:10001 "PST requested" LANG:10027 "PST requested" LANG:10007 "ТеŃŃ‚ запроŃено" 

我运行以下脚本来选择文件并将其导入到新工作表中,但是我不知道在哪里插入代码来更改Charset = "utf-8"

Sub OpenAFile() 'import file

Dim fd As FileDialog
Dim homeWorkbook As Workbook
Set homeWorkbook = ActiveWorkbook
Dim targetBook As Workbook
Dim targetSheet As Worksheet

Application.DisplayAlerts = False

Set fd = Application.FileDialog(msoFileDialogOpen)

FileWasChosen = fd.Show

fd.Execute

Set targetBook = ActiveWorkbook
Set targetSheet = targetBook.Worksheets(1)

targetSheet.Copy After:=homeWorkbook.Sheets(homeWorkbook.Sheets.Count)

Application.DisplayAlerts = True

With homeWorkbook.Sheets(homeWorkbook.Sheets.Count)
    .Name = "Import"
End With

End Sub

它需要这样显示:

lt:3 LANG:10001 "Limit alarm HH suppressed" LANG:10027 "Limit alarm HH suppressed" LANG:10007 "Предел - трев. оповещ-е авар. выс. ур-ня устр-но" 

谢谢您的帮助!

0 个答案:

没有答案