By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,345 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,345 IT Pros & Developers. It's quick & easy.

read word document from access database

P: n/a
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.
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies

P: n/a
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
Nov 21 '05 #2

P: n/a
On Wed, 2 Feb 2005 11:35:36 +0100, "Cor Ligthert" <no************@planet.nl> wrote:

€ 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 ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #3

P: n/a
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

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:tg********************************@4ax.com...
On Wed, 2 Feb 2005 11:35:36 +0100, "Cor Ligthert" <no************@planet.nl> wrote:
€ 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 ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #4

P: n/a
the magic number is 85!

"Tim Murphy" <ne**@msolutions.com.au> wrote in message
news:42***********************@un-2park-reader-01.sydney.pipenetworks.com.au...
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

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:tg********************************@4ax.com...
On Wed, 2 Feb 2005 11:35:36 +0100, "Cor Ligthert" <no************@planet.nl> wrote:

€ 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 ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)


Nov 21 '05 #5

P: n/a
Tim

Thanks for letting us know.

Cor
Nov 21 '05 #6

P: n/a
On Thu, 3 Feb 2005 07:28:19 +1100, "Tim Murphy" <ne**@msolutions.com.au> wrote:

€ 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 ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #7

P: n/a
Can you give us more details please. Source code would be even better.

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:6k********************************@4ax.com...
On Thu, 3 Feb 2005 07:28:19 +1100, "Tim Murphy" <ne**@msolutions.com.au> wrote:
€ 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 ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #8

P: n/a
On Fri, 4 Feb 2005 08:33:33 +1100, "Tim Murphy" <ne**@msolutions.com.au> wrote:

€ 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 ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.