Results 1 to 14 of 14

Thread: [RESOLVED] Binary file in table, problem With adding Row

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Resolved [RESOLVED] Binary file in table, problem With adding Row

    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:
    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
    But on the row "Set oBinaryDataRow = oBinaryDataTab.Rows.Add" code just stopped to work.
    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
    Last edited by Gordan0810; Jan 28th, 2009 at 06:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width