olevb1,
You mention that you succeeded in copying the ole object field to the clipboard using VB/VBA.
If you can show how you did that, I can surely help you to finalize this, all the rest is known to me.
Main Topics
Browse All TopicsI have an access database which contains 3 fields:
Field Name Datatype
1) Id as Text
2) Obj as OleObject
3) Pic as Longbinarydata ( to store .gif/.bitmap )
Now, i want to populate this data in excel spreadsheet.
I tried many options, i could retrieve the text field but the other fields, i could not.
In a crude way i managed to retrieve the data by first copying the object to the clipboard and the pasting it on the excel (ofcourse using 2 seperate programs--VB/Access was one program to copy the object to the clip board & to paste back was VBA / EXcel).
What I want is the entire process of populating the access database should be done by VBA.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Olevb1,
Please try the following code, which of course, needs some adaptation to your own DB names. Also, it requires that you create a form ("EETest" in the macro), which shows all the objects for each record.
You also need to set a reference to the 'Microsoft Excel 8.0 Object Library' in your protect (Tools/references) - (might be 9.0 boject library, if using Office/Excel 2000)
Good Luck
calacuccia
Option Compare Database
Option Explicit
Sub ExportExcel()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim mTbl As Database, mRecSet As Recordset
Dim i As Integer, mIx As Long
Dim mControl1 As Control, mControl2 As Control
Set xlApp = CreateObject("Excel.Applic
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets("Sheet1"
Set mTbl = CurrentDb
Set mRecSet = mTbl.OpenRecordset("Select
mIx = 2
mRecSet.MoveFirst
DoCmd.OpenForm "testEE"
Set mControl1 = Forms("TestEE").Controls("
Set mControl2 = Forms("TestEE").Controls("
Do While Not mRecSet.EOF
DoCmd.GoToRecord acDataForm, "testEE", acGoTo, mIx - 1
For i = 0 To 2
If mRecSet.Fields(i).Type = dbLongBinary Then
If i = 1 Then
mControl1.Action = acOLECopy
xlSheet.Paste xlSheet.Cells(mIx, i + 1)
Else
mControl2.Action = acOLECopy
xlSheet.Paste xlSheet.Cells(mIx, i + 1)
End If
Else
xlSheet.Cells(mIx, i + 1) = mRecSet.Fields(i)
End If
Next i
mIx = mIx + 1
mRecSet.MoveNext
Loop
xlApp.Visible = True
xlBook.Activate
End Sub
Following function will export any SQL statement supplied to it to an Excel spreadsheet. Also, with this code no reference has to be made to Excel 8.0 for it to function.
Public Function Export_SQL_To_Spreadsheet(
On Error GoTo ErrorHandler
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
If rst.EOF Then
MsgBox "No records to export to Excel.", vbOKOnly, "No Export"
GoTo SubExit
End If
Dim objXL As Object, objWkb As Object, i As Integer, j As Integer
Set objXL = CreateObject("Excel.Applic
objXL.Application.workbook
Set objWkb = objXL.Application.ActiveWo
With objWkb
'Export column headers
For i = 1 To rst.Fields.count
.worksheets(1).cells(1, i) = rst.Fields(i - 1).Name
Next i
'Export data
j = 1
While Not rst.EOF
j = j + 1
For i = 1 To rst.Fields.count
.worksheets(1).cells(j, i) = rst.Fields(i - 1)
Next i
rst.MoveNext
Wend
End With
objWkb.Close
objXL.Application.Quit
SubExit:
On Error Resume Next
Set dbs = Nothing
Set rst = Nothing
Set objXL = Nothing
Set objWkb = Nothing
Exit Function
ErrorHandler:
MsgBox "Error " & Err.Number & vbNewLine & vbNewLine & Err.Description
Resume SubExit
End Function
Maathias,
Your code indeed bears some advantages, but the real issue here is the exporting of the OLE Data Fields to Excel, which is absolutely not handled by Excel cells in a normal way, that's why I am working with the at first sight complicated copy to and paste from Clipboard, and also using a form with the OLE Data field contents to be able to copy something.
olevb1,
You mailed me this
"Well i could come out of the database type problem:
The pb is i m mot able to understand what does your
following statement says:
requires that you create a form ("EETest" in the
macro), which shows all the objects for each record
What is expected to do here.
And now i m facing this pb:
Set mRecSet = mTbl.OpenRecordset("Select
PicTable") --> gives type mismatch error-- i m not
able 2 sort this out
Reply Soon,
Bye"
I would prefer if you ask updates in the frame of this question.
Anyhow,
the form you need to make is an Access form which shows the three fields for the export you are trying to do to Excel. I need the form to show these fields for each record, to be able to copy them to the clipboard, and paste them into Excel. The name you choose for the form and the name of both OLE controls is indicated in these two lines
Set mControl1 = Forms("TestEE").Controls("
Set mControl2 = Forms("TestEE").Controls("
The Type mismatch message is probably because you have both DAO en ADO references set in Tools/References for your project as this article explains:
http://support.microsoft.c
You can overcome it by doing this in the declaration section
Dim mTbl As Database, mRecSet As DAO.Recordset
Business Accounts
Answer for Membership
by: olevb1Posted on 2001-12-28 at 04:20:05ID: 6698388
I would be glad if any alternate procedure is suggested, but the procedure should be programmable (done through a code)