Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2004, 05:15 AM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access OLE Merge to Word

I have a database (Access97)in which the table "T_EXERCISES" includes a OLE object Field (OLE_VIEW). I store Word Docs (embedded) in that field. After i put search criteria on a form there is a query which takes the results. All I want to do is export the docs from the query to Word.
I've tried with Publish, Merge but I get null. I think that the problem is that I can't pass through the content of the object (the formated text of the Word docs) so I could simply Copy-Paste it.
What is wrong with the code below?
Why it isn't working?

Dim objWord As Word.Application
Dim objDoc As Object
Dim rCust As Recordset
Dim dbase As Database

Set dbase = CurrentDb()
Set rCust = dbase.OpenRecordset("q_SearchList")

Set objWord = New Word.Application
objWord.Visible = True
Set objDoc = objWord.Documents.Add

objWord.Selection.Text = rCust("OLE_VIEW")
rCust.MoveNext
....


GregoryHu
 
Old March 15th, 2004, 05:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi GregoryHu,

Thanks for your personal message.

Unfortunately, Word automation is not really my cup of tea, so I am afraid I can't help you.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 15th, 2004, 10:51 AM
Authorized User
 
Join Date: Feb 2004
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Data stored in an Access database is not appropriate for pasting into a host application. You can instead open the host from within Access and copy and paste from there. I've attached a link about OLE and graphics but the principles apply to OLE servers.

http://www.ammara.com/articles/imagesaccess.html

You may want to reconsider your design if you objective is to concatenate the data in several fields into a formatted Word document. It may be much easier to use rich text in Access and then copy the recordset fields into one or more Word docs.



Ciao
Jürgen Welz
Edmonton AB Canada
[email protected]
 
Old March 15th, 2004, 11:31 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It depends on how the data is stored in the table. If saved carefully in its raw format it appears as 'Long binary data' and can be extracted and saved to disk then opened in the correct application. If it appears as 'Microosft Word Document' then Access has added extra information and I don't think it can be easily opened directly as a document. If you need more help about the first scenario let me know.



--

Joe
 
Old March 15th, 2004, 01:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gregory

Tour basic problem is that you're storing a whole Word document in an OLE field, in it's own proprietory binary format, and then trying to treat it as a piece of text. It just isn't going to work.

What you need to do is create a temporary Word document from the contents of the OLE field and then open that temp file in Word. I may have the code to do this on my work machine - I'll try and dig it out tommorrow.


Brian Skelton
Braxis Computer Services Ltd.
 
Old May 7th, 2004, 10:18 AM
pbx pbx is offline
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've got a problem like this one...
I transfer data (with ole type column) from access to SqlServer with DTS.
When i extract a document from SqlServer, I can't open it !!!
Help !!!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Merge with Access VBA echovue Access 6 May 5th, 2006 05:11 PM
Access/Vba mail merge to word help alfonse Access VBA 0 July 28th, 2005 05:11 AM
Word E-Mail Merge using Access Tables Richard Lally Access 2 February 7th, 2005 04:48 AM
OLE Automation Access - Word william.murray Access 2 July 13th, 2004 07:23 AM
Access OLE to Word GregoryHu Access VBA 0 March 1st, 2004 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.