我已经尝试了几天来解决这个问题。
我们有一个Lotus Notes数据库,只有在文件中保存文件时才会接受和导入文件
1)在Open Office中打开XLS
2)选择所有单元格(始终是单个工作表)并设置默认格式
3)保存为TXT CSV
4)然后作为导出过程的一部分保存为UTF-8,Field Delimiter =,text Delimiter ="并引用所有TXT细胞
我环顾四周各种各样的作品,似乎无法找到我需要的东西。会喜欢一些帮助
这是我到目前为止所拥有的
Sub OTimport()
ThisWorkbook.ActiveSheet.Cells.ClearFormats
Set wkb = ActiveSheet
Dim fileName As String
Dim MaxCols As Integer
fileName = Application.GetSaveAsFilename("C:\Users\ADMIN\Desktop\Report work\OTIMPORT" & Format(Now(), "DD-MMM-YYYY hh mm AMPM"), "CSV File (*.csv), *.csv")
If fileName = "False" Then
End
End If
On Error GoTo eh
Const adTypeText = 2
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Charset = "UTF-8"
BinaryStream.Type = adTypeText
BinaryStream.Open
For r = 1 To 10
s = ""
C = 1
While Not IsEmpty(wkb.Cells(r, C).Value)
s = s & wkb.Cells(r, C).Value & ","
C = C + 1
Wend
BinaryStream.WriteText s, 1
Next r
BinaryStream.SaveToFile fileName, adSaveCreateOverWrite
BinaryStream.Close
MsgBox "CSV generated successfully"
eh:
End Sub