How to export out the OLE object content to a folder (c:\temp)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chinfk
    New Member
    • Oct 2007
    • 15

    How to export out the OLE object content to a folder (c:\temp)

    Hi Guys,

    I have OLE field in the tables, in the datasheet view, it is written there as "packager". Usually, I insert the field content by insert object ways ( insert a PDF ).

    How should I export all the files / object to a particular folder in C:\Temp ?

    Thanks in advancevd.
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hi, chinfk.

    It seems that there is no way to do it via code as long as Packager object doesn't support automation.
    What do you think about storing the files in BLOBs ? It may be an efficient solution in a case you are storing read-only files.

    Regards,
    Fish

    Comment

    • chinfk
      New Member
      • Oct 2007
      • 15

      #3
      Hi Brother Fish,

      Thanks for your advice, did this feature available in MS access ?

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        Originally posted by chinfk
        Hi Brother Fish,

        Thanks for your advice, did this feature available in MS access ?
        Oh, ye. It is available.

        BLOB may be stored in OLE type table field. In table view you will see "Long binary data" in non-empty field. Access does not have native mechanism to save BLOB to table but with some code it could be easily achieved via Recordset object.

        There are at least two methods to manipulate BLOB in a table field.
        • using GetChunk / AppendChunk methods available both in DAO and ADO
        • using ADODB.Stream object ("Microsoft Activex Data Objects" version at least 2.5 has to be referenced - open Tools > References, uncheck currently referenced ADO library if its version is lower, check reference to the latest version, e.g. in Access2003 ADO 2.8 is available)


        The second method is simpler and faster.

        The following examples assumes that ADODB.Recordset is already opened and its cursor is on an appropriate record. Field storing BLOB has name [oleBLOB].
        • to save file contents to a table as BLOB
          [code=vb]
          Dim stmFileStream As New ADODB.Stream
          Dim RS As New ADODB.Recordset
          ...............
          With stmFileStream
          .Open
          .Type = adTypeBinary
          .LoadFromFile "X:\FileToStore InTable.ext"
          RS![oleBLOB] = stmFileStream.R ead
          RS.Update
          .Close
          End With
          .........
          Set stmFileStream = Nothing
          Set RS = Nothing
          [/code]
        • to save BLOB to disk file
          [code=vb]
          Dim stmFileStream As New ADODB.Stream
          Dim RS As New ADODB.Recordset
          .......
          With stmFileStream
          .Open
          .Type = adTypeBinary
          .Write RS![oleBLOB]
          .SaveToFile "X:\FileName.ex t"
          .Close
          End With
          .........
          Set RS = Nothing
          Set stmFileStream = Nothing
          [/code]


        Regards,
        Fish

        Comment

        • hzetzer
          New Member
          • Apr 2009
          • 1

          #5
          What did you use to format your source so well?

          Thanks, Hans

          Comment

          Working...