By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,224 Members | 1,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,224 IT Pros & Developers. It's quick & easy.

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

chinfk
P: 15
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.
Dec 5 '07 #1
Share this Question
Share on Google+
4 Replies


FishVal
Expert 2.5K+
P: 2,653
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
Dec 12 '07 #2

chinfk
P: 15
Hi Brother Fish,

Thanks for your advice, did this feature available in MS access ?
Dec 13 '07 #3

FishVal
Expert 2.5K+
P: 2,653
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
    Expand|Select|Wrap|Line Numbers
    1. Dim stmFileStream As New ADODB.Stream
    2. Dim RS As New ADODB.Recordset
    3. ............... 
    4. With stmFileStream
    5.     .Open
    6.     .Type = adTypeBinary
    7.     .LoadFromFile "X:\FileToStoreInTable.ext"
    8.     RS![oleBLOB] = stmFileStream.Read
    9.     RS.Update
    10.     .Close
    11. End With
    12. .........
    13. Set stmFileStream = Nothing
    14. Set RS = Nothing
    15.  
  • to save BLOB to disk file
    Expand|Select|Wrap|Line Numbers
    1. Dim stmFileStream As New ADODB.Stream
    2. Dim RS As New ADODB.Recordset
    3. .......
    4. With stmFileStream
    5.      .Open
    6.      .Type = adTypeBinary
    7.      .Write RS![oleBLOB]
    8.      .SaveToFile "X:\FileName.ext"
    9.      .Close
    10. End With
    11. .........
    12. Set RS = Nothing
    13. Set stmFileStream = Nothing
    14.  

Regards,
Fish
Dec 14 '07 #4

P: 1
What did you use to format your source so well?

Thanks, Hans
Apr 3 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.