Embedding a file in a Access DB
Hello everyone,
I new in programming, and I thought I should start with VB6.
I have an Access DB with a table (Updates) that contains a OLE field (Attachment).
I need the code to let me insert a file (no matter what type, it can be a picture, an Outlook mail or any other Office document) from within the program, and then to open it from the RecordSet with a double click on a OLE object for example.
Is that even possible with VB6?
In case it is, I would appreciate very much some code examples for updating and retrieving the object.
Thanks in advance to all readers and posters.
:)
Re: Embedding a file in a Access DB
Have a look at few samples linked to my signature.
Re: Embedding a file in a Access DB
thanks RB, but I had already checked the links in your signature.
I was hoping to get a different answer, with a more global code, since I don't see the way to display the "attachment".
But thanks a lot anyway. :)
Re: Embedding a file in a Access DB
Those samples demonstrate how to save/retrieve file to/from database.
What you do with your file (any type btw) after retrieving is entirely up to you so I am not quite sure I understand your concern about "displaying the attachment".
Re: Embedding a file in a Access DB
Well, I printed your code, kept reading it for many minutes, and finally figured out that you were actually creating a temporary file, using a windows API ( I guess), and then loading it on a picture.
I know, I'm a little slow ;)
With displaying I mean launching, using the explorer Double Click.
I suppose all I have to do is Embed the temporary file on a OLE object and a double click will do the rest.
Thank you again Mr. MVP
Re: Embedding a file in a Access DB
You can simulate a double-click on a file (or a right-click followed by "open"/"print"/etc) by using the ShellExecute API.
For more information about it, see the article How do I open a file/web-page in its default application? from our Classic VB FAQs (in the FAQ forum)
Re: Embedding a file in a Access DB
Thanks!!! I really appreciate your help!!!