我被要求复制以下 Excel VBA 代码发送的文件。问题在于“for”循环中包含的数据的导出。数量“.111”在导出文件中写为“øSã=”,“.222”写为“øSc>”,“.333”写为“ú~ª>”。
我不完全确定这里发生了什么。但无论如何,我将数据发送到的目标遗留系统都能够正确读取这些数据(即,它被转换回原始值)。
有没有人对正在发生的事情以及如何复制此行为以便可以读取我的文件有任何想法?
Type Rigo_File
Status As Integer
Invio As Integer
Codice As String * 13
Quantita As Single
Udm As Integer End Type
Type type_file
Partita As String * 10
Macchina As String * 25
articolo As String * 25
colore As String * 25
note As String * 25
urgenza As Integer
Invio As String * 3
Righi(20) As Rigo_File
End Type
Dim NrOpen As Integer
Dim NomeFile As String, NomeFileTmp As String
Dim Rigo_File
Dim type_file
Dim typeM As type_file
Dim c As Integer
Sub CREATEFILE()
FILEDIR = "C:\"
FILENAMEE = "TESTFILE1.txt"
Partita = Right(Cells(1, 3), 10)
Macchina = Left(Cells(2, 3), 25)
articolo = Left(Cells(3, 3), 25)
colore = Left(Cells(4, 3), 25)
note = Left(Cells(5, 3), 25)
urgenza = CDbl(Cells(6, 3))
With typeM
.Partita = Partita
.Macchina = Macchina
.articolo = articolo
.colore = colore
.note = note
.urgenza = urgenza
.Invio = "001"
For ci = 1 To 20
.Righi(ci).Status = True
.Righi(ci).Invio = 1
.Righi(ci).Codice = Cells(8 + ci, 2)
.Righi(ci).Quantita = Cells(8 + ci, 3)
.Righi(ci).Udm = 1
Next ci
End With
NrOpen = FreeFile
On Error GoTo 0
Open FILEDIR & FILENAMEE For Random Access Write Shared As #NrOpen Len = Len(typeM)
Put #NrOpen, 1, typeM
Close #NrOpen
结束子