473,657 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read word document from access database

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
8 2808
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.Memor yStream(arrImag e, 78, arrImage.Length - 78)

I hope this helps
(I am absolute not sure)

Cor
Nov 21 '05 #2
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.Memor yStream(arrImag e, 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******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #3
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************ ***********@sws pectrum.com> wrote in message
news:tg******** *************** *********@4ax.c om...
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.Memor yStream(arrImag e, 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******@amerit ech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #4
the magic number is 85!

"Tim Murphy" <ne**@msolution s.com.au> wrote in message
news:42******** *************** @un-2park-reader-01.sydney.pipen etworks.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************ ***********@sws pectrum.com> wrote in message
news:tg******** *************** *********@4ax.c om...
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.Memor yStream(arrImag e, 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******@amerit ech.net
Microsoft MVP (Visual Basic)


Nov 21 '05 #5
Tim

Thanks for letting us know.

Cor
Nov 21 '05 #6
On Thu, 3 Feb 2005 07:28:19 +1100, "Tim Murphy" <ne**@msolution s.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******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #7
Can you give us more details please. Source code would be even better.

"Paul Clement" <Us************ ***********@sws pectrum.com> wrote in message
news:6k******** *************** *********@4ax.c om...
On Thu, 3 Feb 2005 07:28:19 +1100, "Tim Murphy" <ne**@msolution s.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******@amerit ech.net
Microsoft MVP (Visual Basic)

Nov 21 '05 #8
On Fri, 4 Feb 2005 08:33:33 +1100, "Tim Murphy" <ne**@msolution s.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******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7680
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be printed on its own page which I've set up as a report and that's working fine. Accompanying each job is a Word (or Excel) document. Most jobs will have Word (or Excel) documents unique to the record. I know how to establish a hyperlink field...
41
6086
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there is one row containing picture(s) as well. So far, what I did is doing it manually for each word docs I have. Select Table Convert Table to Text(I use ^ character for delimiter)
4
15822
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can write a VB script, to be executed either within Access or executed at the CMD prompt, which will loop through all the records and open the document object and save it to a Word document that I can access from Windows Explorer. An additional info...
4
6285
by: Dadio | last post by:
Hello On my Access database form I have a command button which opens a Word mail merge document in which I have created a number of fields (Title, FirstName, LastName, Address1 etc.) I would like to be able to populate the Word document with the contents of the currently selected Access record so that when I press the button in Access, Word opens with the appropriate fields populated and ready to print. It is a "one off" event which I...
5
2591
by: rick m | last post by:
We have a fairly good sized Access database that contains some info on the children our agency sees. We also have 40+ templates that require some info from the database be inputted into them, such as the name of the child, their address, etc. At this time staff will look into the database for that info and enter it into the form. Management wants to automate this a bit so each of these templates is a report. That leads to my question. ...
2
2467
by: reb0101 | last post by:
hey all, I would very much appreciate any help or ideas on how to do this as I am stumped. I need to develop an access database to track documents but also link to them. I’ll explain what it needs to do; Every day there is a numbered (and titled) Word format document that is sent. Most, but not all of the time an accompanying excel file is also sent. The excel file is used for updates to the word document of the same name. Lets say...
8
13327
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to make the mail merge seamless to the user so all they have to do is click on the command button and the letters are generated. For the button I created an event procedure with the following code: Private Sub RunLetters_Click()
3
2099
by: N. Graves | last post by:
I've searched Google for a couple of hours and I did not find an answer to my question. Thanks for your interest! Is there a way to update a table with a new(updated) word Document? I can do this internally to Access but I need an ASP web page to update the word document then allow the user to download the Access database. got any suggestion?
4
12427
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.