embedding word doc into access ole db field

U

Uri Kahn

I have defined an access database table to have an "ole
object" field. I want to insert via vba code using ado
the currently active word document into this field.
i tried the following in a button in a userform activated
by a macro in word:

dim db as new adodb.connection
dim rs as new adodb.recordset

db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..."
rs.Open "select * from Table1;", db, adOpenDynamic,
adLockOptimistic

rs.AddNew
rs("Attachment") = ActiveDocument
rs.Update

but i get an error "Multi-step ole db operation generated
errors..."

i also tried:

rs("Attachment").appendchunk (ActiveDocument)

here i got no error message - but when opened the database
table, i could see in the field "Long Binary Data" instead
of "Microsoft Word Document" (as i see when manually
embedding an object) and also double clicking on it
returned an error instead of opening the doc.

could anyone suggest how to fix this problem?
 
C

Cindy M -WordMVP-

Hi Uri,

You need to ask this in an Access or an ADO newsgroup. I
rather suspect you'd have to do this with the closed, Word
document FILE (*.doc). And I suspect you have to do something
with Stream or so... But there's certainly no interface for
doing this in Word's object model.
I have defined an access database table to have an "ole
object" field. I want to insert via vba code using ado
the currently active word document into this field.
i tried the following in a button in a userform activated
by a macro in word:

dim db as new adodb.connection
dim rs as new adodb.recordset

db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..."
rs.Open "select * from Table1;", db, adOpenDynamic,
adLockOptimistic

rs.AddNew
rs("Attachment") = ActiveDocument
rs.Update

but i get an error "Multi-step ole db operation generated
errors..."

i also tried:

rs("Attachment").appendchunk (ActiveDocument)

here i got no error message - but when opened the database
table, i could see in the field "Long Binary Data" instead
of "Microsoft Word Document" (as i see when manually
embedding an object) and also double clicking on it
returned an error instead of opening the doc.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

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