472,145 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

I need help from VB/VBS experts: exporting Access OLE object (Word document) to a file

I have been fighting with this for days and your expert help is
needed! Below is the code I am executing which results with "Object
doesn't support this property or method". The error is occuring on
the "With Me.OLEObject" line. I am trying to extract a Word
document(OLE object) from an Access database, for each record in the
table, and save it as a Word Document. The 4th field of each record
is a OLE object type.

I may be getting my terms mixed up (i.e. VB, VBScript and VBA). I
just want to execute a program from the windows shell or from within
Access which will loop through all the records of the said table and
create 1 Word Document file per database record using the OLE object
field as the source.

This is a continuation of my recent post "Exporting/Extracting an
Access OLE object (Word document) to a Word document file" in several
newsgroups. Example code will be greatly appreciated - please
indicate if it is VB, VBS or VBA code.

Thank you for your help!

My Code:

dim conn
set conn = CreateObject("ADODB.Connection")
conn.Open "provider=microsoft.jet.oledb.4.0;data

dim rs
dim NewDoc
set rs = CreateObject("ADODB.Recordset")
'rs.Open "select * from tblTemp", conn
rs.Open "tblTemp", conn

'rs.BOF and rs.EOF = True means that there is no records

while not rs.EOF
set srv = rs.Fields(1)
set ttl = rs.Fields(2)
NewDoc = "c:\tst\" & srv & "." & date() & "." & ttl & ".doc"
' WScript.Echo NewDoc
oObj = rs.Fields(3) ' rs.Fields(3) is a OLE object field
oObj.Class = "Word.Document"
oObj.Verb = acOLEVerbOpen
oObj.Action = acOLEActivate
oObj.Object.Application.Documents.Item(1).SaveAs NewDoc
oObj.Action = acOLEClose
End With

Nov 13 '05 #1
0 3153

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Fly Girl | last post: by
20 posts views Thread by Stephan Golux | last post: by
1 post views Thread by Thankful Idiot via AccessMonster.com | last post: by
2 posts views Thread by Mux | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.