To store the OLE object in database, user can use CreateEmbed method. In this article we demonstrate how the object of particular class is stored in OLE field. We can store any kind of OLE object like as Bitmap images, snapshots, photoshop image, Microsoft graft chart and we can also stores the Microsoft word, excel, power-point file as object. In this article we visually demonstrate the all the important steps to accomplish this.
Firstly we need to create table, that is for storing the path, extension, oleClass. After this create a form as shown in Fig 1.1. On the header section we need to specify the Folder path , extension and OLEClass as we specify in Fig 1.1. And other fields keep bound with table corresponding fields.
After code on "load files", we need to test it. When we are click on button, then the OLE object is stored in table fields as show in Fig 1.2. We can view the OLE object just by click on that field.
Option Compare Database Private Sub cmdbtn_Click() Dim fld_nam As String Dim fld_path As String Dim fld_file As String fld_nam = Me!SearchFolder fld_path = fld_nam & "\" & "*." & [SearchExtension] fld_file = Dir(fld_path, vbNormal) Do While Len(fld_file) <> 0 OLEPath = fld_nam & "\" & fld_file OLEFile.Class = [OLEClass] OLEFile.OLETypeAllowed = acOLEEmbedded OLEFile.SourceDoc = [OLEPath] OLEFile.Action = acOLECreateEmbed fld_file = Dir DoCmd.RunCommand acCmdRecordsGoToNew Loop End Sub
It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. ERP Makers will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.