read word document from access database

T

Tim Murphy

How do you read/write a Word document embedded in an OLE Object field in an
Access table with VB.NET?

I have an Access application where users are creating and editing Word
documents that are embedded in the database. I need to write a VB.NET
application to routinely read the contents of these Word documents. I've
written code that uses automation to open a Word document saved on disk and
read the contents of the document but I don't know how to do the same if the
document is inside a database.
 
C

Cor Ligthert

Tim,

Mostly is that done using a blob field.
In an oledb file there is a header in that blob.
I have this sample for a picture in OleDB in a SQLserver, I assume that it
is the same for the word document in access however this does not have to be
true.

Dim arrImage() As Byte = DirectCast(rdr.Item("Photo"), Byte())
Dim ms1 As New System.IO.MemoryStream(arrImage, 78, arrImage.Length - 78)

I hope this helps
(I am absolute not sure)

Cor
 
P

Paul Clement

¤ Tim,
¤
¤ Mostly is that done using a blob field.
¤ In an oledb file there is a header in that blob.
¤ I have this sample for a picture in OleDB in a SQLserver, I assume that it
¤ is the same for the word document in access however this does not have to be
¤ true.
¤
¤ Dim arrImage() As Byte = DirectCast(rdr.Item("Photo"), Byte())
¤ Dim ms1 As New System.IO.MemoryStream(arrImage, 78, arrImage.Length - 78)
¤
¤ I hope this helps
¤ (I am absolute not sure)


The header offset position depends upon the type of document. For Word files I believe it's 40.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
T

Tim Murphy

78 nor 40 works. In fact I think its more than just a header offset. Doing a
binary compare of the file I created in word then inserted into the database
and out again they look very different. Some parts are similar but most
noticeably the end section of the original looks to be at the top of the
extracted document.

Any more clues? I've done a google but I most be using the wrong keywords.
Surely someone has been faced with this before me!

Tim

 
T

Tim Murphy

the magic number is 85!

Tim Murphy said:
78 nor 40 works. In fact I think its more than just a header offset. Doing a
binary compare of the file I created in word then inserted into the database
and out again they look very different. Some parts are similar but most
noticeably the end section of the original looks to be at the top of the
extracted document.

Any more clues? I've done a google but I most be using the wrong keywords.
Surely someone has been faced with this before me!

Tim
 
P

Paul Clement

¤ the magic number is 85!
¤

The Classic VB code I have searches for the "ÐÏ" character string (without the quotes) in order to
determine the offset. This might be a safer bet if you find that some Word documents have a
different offset location.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
P

Paul Clement

¤ Can you give us more details please. Source code would be even better.
¤

I'll see if I can dig something up or port the existing Classic VB code.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

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