To to pull out OLE Objects

G

Guest

I need to know how I can pull out an OLE Object. In the field it just says
Long Binary Data. The data that is stored in the OLE Object is a RTF file.
 
S

Stephen Lebans

Hey Van,
that solution is for OLE embedded Images only. The OP was requesting a
solution for embedded RTF docs. If the original RTF file was simply
copied verbatim as Binary data then you can do something as simple as:

' Create a form with an OLE Frame control bound to the field containing
the RTF data.
Private Sub cmdSave_Click()

On Error GoTo Err_cmdSave_Click

Dim a() As Byte
Dim lTemp As Long
Dim sl As String

lTemp = LenB(Me.olePicture.Value)
ReDim a(0 To lTemp)


' Copy the contents of the OLE control
a = Me.olePicture.Value
' Setup our filename
sl = Me.numPhotoID & ".rtf"

Open sl For Binary Access Write As #1 'FileNum1s
Put #1, , a
Close #1

Exit_cmdSave_Click:

Exit Sub

Err_cmdSave_Click:

MsgBox Err.Description

Resume Exit_cmdSave_Click


End Sub
'------------------------------------------------------------

If the RTF file was truly inserted via an OLE Server capable of serving
RTF data then you would use the very same logic as the OLEtoDisk
solution but simply change the Clipbaord functions to retreive RTF
instead of MEtafile formatted data. RTF Clipboard routines are here:
http://www.lebans.com/copygetrtffromclipboard.htm


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

The RTF notes in your database is set as a Memo. Mine is set up as OLE
Object. My database was created by saving a MS Project file as a database
file. All notes in the MS Project was saved as RTF in an OLE Object field
when converted to the database. I am currently using ASP and VB to try to
get this RTF note out.
 
S

Stephen Lebans

Did you not look at option #2 within my original reply? It addresses the
issue for OLE objects.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


mxiong said:
The RTF notes in your database is set as a Memo. Mine is set up as OLE
Object. My database was created by saving a MS Project file as a database
file. All notes in the MS Project was saved as RTF in an OLE Object field
when converted to the database. I am currently using ASP and VB to try to
get this RTF note out.
 
G

Guest

I believe I did. I downloaded the zip file located at the link you provided.
Took a look at the database and the RTF field was data type memo. This is
my first time using VB so the majority of the code I'm seeing for the button
"Copy RTF from Bound control to ClipBoard and then from Clipboard to Unbound
RTF control" makes no sense to me at all. The comments are too vague. Also,
I'm not looking to view the RTF in a form created in Access...I need to get
it out to a web front end. Sorry, but can you be more clear/specific?
 
S

Stephen Lebans

In the original post I stated:

This means you would have to use the foundation of the OLEtoDisk
solution and the Clipboard RTF routines.

It is obvious from your statements that you are not familiar with
coding in VB/VBA. Therefore there is no existing method to
programmatically extract the contents of your RTF OLE object field.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Alright. So I got the OLEtoDisk solution. Thought I would play with that
first. Got to step 8 and got this error: ExportOLEtoJpegV12:2753 A problem
occurred while Microsoft Access was communicating with the OLE server or
Active X Control. Now what do I do from here?

Also, what are the Clipboard RTF routines in CopyGetRTFfromClipboard? If
I'm correct, there is vb code only in the button, right? So, I'm going to
guess that routines are functions such as Function ClipBoard_GetRTFText()?

Errr...HELP. Sorry, but I'm totally a newbie at this! Thanks for all the
help so far!

-mxiong
 
S

Stephen Lebans

Let's start over.

1) Is this a one shot deal that you need to pull the RTF data out of the
table?

2) How many records are we talking about?

3) What word processor was used as the OLE Server to insert the RTF data
into the OLE object field?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

Your question:
1) Is this a one shot deal that you need to pull the RTF data out of the
table?

Yes. I need to be able to pull out this RTF notes and put it on a web front
end.

Your question:
2) How many records are we talking about?

Varies. Right now, there are 3 projects. Each project has 90 tasks. All
tasks are stored into one table (as created by MS Project). However, not all
task have a note.

Your question:
3) What word processor was used as the OLE Server to insert the RTF data
into the OLE object field?

MS Project does it for me. According to MS, "Storing notes has been
simplified in Microsoft Project 2000. Task notes (rich text) are now stored
in the TASK_RTF_NOTES column in the MSP_TASKS table..."

If that's not enough, I can try to explain what I'm doing again:

We keep track of our projects using MS Project but there are not enough
licenses for everyone and we can't afford to send everyone to a MS Project
course. So, the alternative is to convert the .mpp file into a .mdb file
since MS Project can be in a database format. We went ahead and created a
project using MS Project, then saved it as a .mdb file using the Save As
command. When we do that, MS Project will create the entire database for us.
In doing do, MS Project stores the notes in a OLE Object field. Once the
database is created, the data is pulled out to a web frontend using ASP.
However, being that the note is an image, I need to do extra stuff to get the
note out onto the web frontend. I can't just say
response.write(rsObj("TASK_RTF_NOTES")) because that will just output a whole
bunch of symbols.

If you have MS Project on your computer, there is document regarding MS
Project database format. For me, the path is:
C:\Program Files\Microsoft Office\Office\1033\PROJDB.HTM

Maybe this will help you understand what I'm doing.

Thank you.

-mxiong
 
G

Guest

Stephen Lebans,

Thanks for all the help you've given me, but the solution has been found. I
found this article: http://www.4guysfromrolla.com/webtech/060100-1.shtml and
was able to get the darn RTF data out from the database. Just in case people
can't get to the above article, here's the code that the article provided:

<%
'Step 1: Read in the employee ID from the querystring
Dim iEmployeeID
iEmployeeID = Request.QueryString("EmployeeID")

'Step 2: grab the picture from the database
Dim objConn, objRS, strSQL
strSQL = "SELECT Picture FROM Employee WHERE EmployeeID = " & iEmployeeID

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=EmployeeDatabase"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn

'Step 3: Set the ContentType to image/jpeg
Response.ContentType = "image/jpeg"

'Step 4: Use Response.BinaryWrite to output the image
Response.BinaryWrite objRS("Picture")

'Clean up...
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
%>

I had to substitute this line of the code: objConn.Open
"DSN=EmployeeDatabase" with: objConn.Open "DRIVER={Microsoft Access Driver
(*.mdb)}; DBQ=" & Server.MapPath("dntProjects.mdb").

The output came out with some extra information in the header/footer, but
cleaning that up shouldn't be so hard. Hopefully this will help everyone
else who's having the same problem with pulling out the data that is stored
in a field with OLE Object data type!

Keep in mind the above code came from
http://www.4guysfromrolla.com/webtech/060100-1.shtml.

-mxiong
 
G

galinderas

lo e conseguio escribir y leer
Stephen Lebans said:
In the original post I stated:


This means you would have to use the foundation of the OLEtoDisk
solution and the Clipboard RTF routines.

It is obvious from your statements that you are not familiar with
coding in VB/VBA. Therefore there is no existing method to
programmatically extract the contents of your RTF OLE object field.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

MS Project stores RTF in the database in a field with data type OLE Object.
When the database is opened using MS Access, all you see is "Long Binary
Data". Images are stored in this way as well.

-mxiong
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top