Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

importing word doc into ole field

0 views
Skip to first unread message

Matt Trossen

unread,
Sep 12, 2000, 10:58:55 PM9/12/00
to
Hey All,

I've searched and searched, can't seem to find sample code!

I need to create a procedure for importing a word doc into my table. I
have the table set up with the ole column and a text field with the file
location and name in it ready to go. I just don't know the right way to
code it. If someone can let me know I'd appreciate it greatly.

I'm figuring to use an addnew for a recordset like below.

*******

rsttbldocuments.addnew
rsttbldocuments!candidateid = currentcandidateid
rsttbldocuments!date = date
rsttbldocuments!thedocument = ??????
rsttbldocuments.update

Simon Lewis

unread,
Sep 13, 2000, 3:00:00 AM9/13/00
to
Hi Matt,

Use a bound object frame control to do this - it 'knows' how to create OLE
objects from files (just loading the file's contents into the field won't
work). The code is quite simple, something like:
With frm.bofObject
.OLETypeAllowed=acOLEEmbedded
.SourceDoc="..." 'set this to the document's path
.Action=acOLECreateEmbed
End With

To do this from a procedure in a standard module, you will need to open the
form (probably hidden), locate the correct record, run the code above, then
close the form.

----
Simon Lewis


"Matt Trossen" <in...@trosseninc.com> wrote in message
news:39BEED6F...@trosseninc.com...

Matt Trossen

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to

Hey Simon,

Your help gets me a step in the right direction but I'm still a bit
lost.

First off: I need to load word docs in 2 ways. 1) If I'm currently
viewing the right record on the main form I have a button to "add a
document" in which it will take the file location from a text field and
create a new record in the related "documents" table adding the current
record's ID as the foreign key. 2) create an import form which has the
location of a folder containing many word docs and creates a new record
for each one it finds. I currently have this type of import completely
functional for text files. The only difference being it imports the text
file into a memo field in the main table and the word docs will need to
go into the "documents" table while creating an associated blank record
in the main table. (I'll then copy the word doc text into the main
table's memo field.)

On my main form I want to have a list box with the names of any
documents the records have in it and the user can double click on one of
the names to open the viewer on that document. (I don't know how to
accomplish this yet. I'm thinking I need to base the list box on a query
of the names in the "documents" table for the current record ID.

All that being said I think your suggestion will work for #1 but not #2

It sounds like I need to have my "add a document" button open a second
form which has the browse for file function and bound object you
mention. Then run the code and close the form and then requery the list
box to update it. Is this right?

for #2 I don't want to have to use a form or bound control as it sounds
very slow. Isn't there a way I can put some code in my loop code as it
runs through the files in the folder and have it take the file and
create the bound object on the fly? Or am I stuck using a form and
field? Wouldn't this open MS Word each time?


Thanks again!

Matt

Simon Lewis wrote:
>
> Hi Matt,
>
> Use a bound object frame control to do this - it 'knows' how to create OLE
> objects from files (just loading the file's contents into the field won't
> work). The code is quite simple, something like:
> With frm.bofObject
> .OLETypeAllowed=acOLEEmbedded
> .SourceDoc="..." 'set this to the document's path
> .Action=acOLECreateEmbed
> End With
>
> To do this from a procedure in a standard module, you will need to open the
> form (probably hidden), locate the correct record, run the code above, then
> close the form.
>
> ----
> Simon Lewis
>
> "Matt Trossen" <in...@trosseninc.com> wrote in message
> news:39BEED6F...@trosseninc.com...

0 new messages