Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Otis Hunter
Guest
 
Posts: n/a
#1: Nov 13 '05
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!

Stephen Lebans
Guest
 
Posts: n/a
#2: Nov 13 '05

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


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] (alick@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" <junk1acct@yahoo.com> wrote in message
news:2a61800f.0407101323.cd2bc28@posting.google.co m...[color=blue]
> 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![/color]

Otis Hunter
Guest
 
Posts: n/a
#3: Nov 13 '05

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


"Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdotcom@linvalid.com> wrote in message news:<EPZHc.72122$Np3.3469550@ursa-nb00s0.nbnet.nb.ca>...[color=blue]
> 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] (alick@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" <junk1acct@yahoo.com> wrote in message
> news:2a61800f.0407101323.cd2bc28@posting.google.co m...[color=green]
> > 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![/color][/color]

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!
Stephen Lebans
Guest
 
Posts: n/a
#4: Nov 13 '05

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


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" <junk1acct@yahoo.com> wrote in message
news:2a61800f.0407101943.df5471c@posting.google.co m...[color=blue]
> "Stephen Lebans"[/color]
<ForEmailGotoMy.WebSite.-WWWdotlebansdotcom@linvalid.com> wrote in
message news:<EPZHc.72122$Np3.3469550@ursa-nb00s0.nbnet.nb.ca>...[color=blue][color=green]
> > Otis please stop multiposting. Instead crosspost to all of the[/color][/color]
relevant[color=blue][color=green]
> > NG's at one time.
> >
> > A quick search on GoogleGroups would have yielded the desired[/color][/color]
solution[color=blue][color=green]
> > based on Word Automation from within Access. Here is a sample post:
> >
> > From: Alick [MSFT] (alick@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" <junk1acct@yahoo.com> wrote in message
> > news:2a61800f.0407101323.cd2bc28@posting.google.co m...[color=darkred]
> > > I have been given an Access Database which contains a table that[/color][/color][/color]
has[color=blue][color=green][color=darkred]
> > > an OLE object field that contains a Word document. That table[/color][/color][/color]
contains[color=blue][color=green][color=darkred]
> > > 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[/color][/color][/color]
document[color=blue][color=green][color=darkred]
> > > object and save it to a Word document that I can access from[/color][/color][/color]
Windows[color=blue][color=green][color=darkred]
> > > Explorer. An additional info is that I would like to[/color][/color][/color]
export/extract it[color=blue][color=green][color=darkred]
> > > 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[/color][/color][/color]
timestamp[color=blue][color=green][color=darkred]
> > > (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[/color][/color][/color]
DOCUMENT[color=blue][color=green][color=darkred]
> > > = 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.[/color][/color][/color]
Now[color=blue][color=green][color=darkred]
> > > that I think of it, I guess I would have to build into the script[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > 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![/color][/color]
>
> 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![/color]

David W. Fenton
Guest
 
Posts: n/a
#5: Nov 13 '05

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


"Stephen Lebans"
<ForEmailGotoMy.WebSite.-WWWdotlebansdotcom@linvalid.com> wrote in
news:39jIc.72556$Np3.3502204@ursa-nb00s0.nbnet.nb.ca:
[color=blue]
> If you search on GoogleGroups you will find several threads on how
> to save embedded Word docs to seperate files.[/color]

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
Closed Thread