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

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

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


P: n/a
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] (al***@online.microsoft.com)
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.
"Otis Hunter" <ju*******@yahoo.com> wrote in message
news:2a*************************@posting.google.co m...
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!


Nov 13 '05 #2

P: n/a
"Stephen Lebans" <Fo****************************************@linval id.com> wrote in message news:<EP*********************@ursa-nb00s0.nbnet.nb.ca>...
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] (al***@online.microsoft.com)
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.
"Otis Hunter" <ju*******@yahoo.com> wrote in message
news:2a*************************@posting.google.co m...
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!


Please excuse my cross post - I posted to just one group and I did not
get a response so today I posted to other groups. What is the proper
way I should go about getting a response to 1 post when it isn't clear
the exact right group to post to? Anyway, please except my apology.
I also have spent over 3 hours trying to find a post that would answer
my question before I posted and I did not get satisfaction - I really
did try to be created with my searches. Bottom line, thank you for
your help!
Nov 13 '05 #3

P: n/a
No need to apologize Otis. Just remember to cross post to mulitple
groups within a single post rather than posting a single message
individually to multiple groups.

If you search on GoogleGroups you will find several threads on how to
save embedded Word docs to seperate files.

Good Luck.
:-)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Otis Hunter" <ju*******@yahoo.com> wrote in message
news:2a*************************@posting.google.co m...
"Stephen Lebans"

<Fo****************************************@linval id.com> wrote in
message news:<EP*********************@ursa-nb00s0.nbnet.nb.ca>...
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] (al***@online.microsoft.com)
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.
"Otis Hunter" <ju*******@yahoo.com> wrote in message
news:2a*************************@posting.google.co m...
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!


Please excuse my cross post - I posted to just one group and I did not
get a response so today I posted to other groups. What is the proper
way I should go about getting a response to 1 post when it isn't clear
the exact right group to post to? Anyway, please except my apology.
I also have spent over 3 hours trying to find a post that would answer
my question before I posted and I did not get satisfaction - I really
did try to be created with my searches. Bottom line, thank you for
your help!


Nov 13 '05 #4

P: n/a
"Stephen Lebans"
<Fo****************************************@linval id.com> wrote in
news:39*********************@ursa-nb00s0.nbnet.nb.ca:
If you search on GoogleGroups you will find several threads on how
to save embedded Word docs to seperate files.


But has anyoned figured out a way to extract programmatically files
that are of different types? I had a database once that had Word,
Excel and PowerPoint files in it. I could never figure out how to
programmatically figure out which kind of file it was so that it
could be saved out to the file system.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.