Hello all,
I have code in Word macro which is reading file from the disk and converting it to binary. This binary should be inserted in the internal table (Dim As object) for further posting.
Here is the code:
But on the row "Set oBinaryDataRow = oBinaryDataTab.Rows.Add" code just stopped to work.Code:Sub Read_File(FileNameFull As String) Dim oBinaryDataTab As Object Dim oBinaryDataRow As Object Dim lBytesToRead As Long Dim iNumChars, i As Integer Dim s1022, s2044, sX As String Dim fs, f, ts As Object Dim ReadFile As String ' Actually does the work of uploading the document in 1022 byte pieces. ReadFile = 0 Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFile(FileNameFull) Set ts = f.OpenAsTextStream(1, -2) lBytesToRead = f.Size ReadFile = f.Size Do While ts.AtEndOfStream <> True If lBytesToRead < 1022 Then iNumChars = lBytesToRead Else iNumChars = 1022 End If s1022 = ts.Read(iNumChars) s2044 = "" For i = 1 To Len(s1022) sX = Hex$(CByte(Asc(Mid(s1022, i, 1)))) If Len(sX) = 1 Then sX = "0" + sX End If s2044 = s2044 + sX Next i Set oBinaryDataRow = oBinaryDataTab.Rows.Add oBinaryDataRow("LINE") = s2044 lBytesToRead = lBytesToRead - iNumChars Loop End Sub
Can somebody give me a hint how to proceed?
I also tried to Dim oBinaryDataTable As Table and oBinaryDataRow as Row with the same result.
TIA
Gordan




Reply With Quote