Exporting/Extracting an Access OLE object (Word document) to a Word document file

O

Otis Hunter

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 is that I would like to export/extract it
to a Word document with a name that is stored in one of the other
fields of that record. I would also like to append a date timestamp
(YYYYMMDDHHMMSS) to the Word documents name just in case the name
field is not unique.

For example:

NAME DOCUMENT
docNameA Microsoft Word Document
docNameB Microsoft Word Document
docNameB Microsoft Word Document

The above table contains two fields, NAME = text datatype and DOCUMENT
= OLE object datatype. I would like loop through the 3 records and
create 3 Word documents with the names of docNameA20040708135601,
docNameB20040708135723 and docNameB20040708135724 respectively. Now
that I think of it, I guess I would have to build into the script a
second delay to ensure unique document names.

Anyway, your help with either example code or a point in the right
direction will be tremendously appreciated!
 
S

Stephen Lebans

Otis please stop multiposting. Instead crosspost to all of the relevant
NG's at one time.

A quick search on GoogleGroups would have yielded the desired solution
based on Word Automation from within Access. Here is a sample post:

From: Alick [MSFT] ([email protected])
Subject: RE: Convert ole from embedded to linked


View this article only
Newsgroups: microsoft.public.access.modulesdaovba
Date: 2003-11-26 04:19:48 PST


Hi Jeff,

We need to save the embedded object to a file and then relink the
object.
The saving code will like:

Dim NewDoc As String
DocPath = "c:\worddoc.doc"
With Me.OLEObject
.Class = "Word.Document"
.Verb = acOLEVerbOpen
.Action = acOLEActivate
.Object.Application.Documents.Item(1).SaveAs DocPath
.Object.Application.Quit
.Action = acOLEClose

End With

Please feel free reply to the threads if you have any questions or
concerns.


Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provided "AS IS" with no warranties, and confers no
rights.



--

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

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