Merge a Word-object in an Access table

M

MatsS

I have a lot of formated Word text, stored as OLE-objects in an Access table.

Using Mail-merge I try to put these object into a new Word document.

Instead of inserting the Word-objects I get a short notice - "Long binary or
text value".

If I copy it and "Paste special" / "as Word text" I can get it back into Word.

Is there a simple way?
 
P

Peter Jamieson

Is there a simple way?

No.

If all your objects contain pictures in format(s) that Word can import via
INCLUDEPICTURE, you can do it as long as you can export your pictures to
files whose names are related to a field in the appropriate record (e.g. if
you have a field called PicturePath containing the path name of the
picture, you could use something based on

{ INCLUDEPICTURE "{ MERGEFIELD PicturePath }" }

For objects in general, you cannot use this approach. You may be able to do
it using VBA - in Word 2002/2003 you may be able to use the mailmerge events
of the Word object model to retrieve the object and insert it. In older
versions of Word you would need to merge to an output document and find some
way to insert the objects, or write some code that completely replaces
Word's merge.
 
M

MatsS

"Peter Jamieson":
No.

If all your objects contain pictures in format(s) that Word can import via
INCLUDEPICTURE

It is word formated text. The reason why I want to use OLE is that it
contains formated word text. It will contain Greek/Swedish characters,
numbered list etc.

Should I store it as another data type?

Mats
 
P

Peter Jamieson

Should I store it as another data type?

Unfortunately, Word merge will not recognise formatting in any kind of text
you store in Access. You have to put the text somewhere else, or ensure that
it is outside Access when you perform the merge, or be willing to fetch the
text programmatically (along the lines I suggested in my previous message).

Word will recognise formatting if the data source is a Word document and you
use e.g.

{ mytextfield } rather than { MERGEFIELD mytextfield }

However, I would test that that works for you before committing to it. (In
fact, the same is true for all these methods, particularly since INCLUDETEXT
does not appear to be as reliable as it used to be, but also because the
more complicated the text & layout, the less likely that it will be included
as you hoped).

If you can keep your texts outside Access then you need something in each
Access record to tell you which text to insert. You can then use the trick I
mentioned earlier except using INCLUDETEXT rather than INCLUDEPICTURE. You
can keep each text in a separate file, and use e.g.

{ INCLUDETEXT "{ MERGEFIELD textfilepath }" }

Or you can put all the texts in a single file and use bookmarks to identify
them, and use e.g.

{ INCLUDETEXT "c:\textfilepath\mytexts.doc" "{ MERGEFIELD bookmarkname }" }

Or some combination of the two.

If you want to keep your texts in Access, the main thing to think about is
how you are going to get them out again - a .doc file would have to be
stored as an object AFAIK, whereas you could probably store .rtf or .htm
text as "plain text" (containing all the necessary formatting codes of
course) in a memo field, then export each text into a .rtf or .htm file.
[[You might even be able to do this "on demand" by using DDE to connect to
Access, using a query as the data source, and having that query reference a
user-defined (VBA) function in Access that exports the data for the current
record. I experimented with this once and it seemed to work for small record
counts, but it probably won't scale up for larger record counts and is
probably not worth pursuing]]
 

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