Problem with including recipients to mail merge

G

Gorlach

Hello!

I create simple validator add-in for mail merge and meet the following
problem. For example, I have 200 recipients in my data source, and 100
from them are included to mail merge (in other words, 100 addresses
are checked in "Mail Merge Recipients" window, and 100 addresses are
unchecked).

When I click "Validate" in "Mail Merge Recipients" window, my
validator load *ALL* addresses (both checked and unchecked).

1. When the address is checked, my validator can exclude it from
merge; it can also include it back (I can swicth .Included property as
many times as I wish within MailMergeDataSourceValidate -- and all
work as expected).

2. But when I try to include unchecked address to mail merge, nothing
happen! I modify .Included property and the result of operation is
S_OK; value of this property is also changing! But when my validator
return control to MS Word, "Mail Merge Recipients" show this address
as unchecked. And it really still unchecked.

Is this behaviour is normal or it is a bug? Any suggestions? My
verifier should verify only included addresses? I work with Word 2002
10.4219.4219 SP-2.

Thanks,
Alexander Gorlach
 
G

Gorlach

Hello again!

I found, that my problem is related to Word object model limitations.
I create another windowless simple "validator" add-in, it include all
contacts to mail merge -- and it work well.

My validator add-in create the window like "Mail Merge Recipients".
Window procedure of my window placed in the same thread as procedure
of "Mail Merge Recipients" window; all my calls to Word object model
are within the thread of OnMailMergeValidate call. So, it is not
multi-threading limitation.

Can anyone point me to right direction? Today, I see only one
solution: create my window at another thread and suspend Word thread
until user work with my add-in. But it is not good way, because Word
UI will not be painted while thread is suspended.

Please, help!
 
G

Gorlach

Hello!

Uff, solved! MSDN (April 2003) sample for ActiveRecord property:

'Set the active record equal to the first included
'record in the data source
.ActiveRecord = 1
......
'Move the record to the next record in the data source
.ActiveRecord = .ActiveRecord + 1

This sample is not correct. Word 2002 SP2 don't understand record
number in ActiveRecord property. It will work from time to time,
sometime it will generate error 0x800a16dd (or 5833 in VB syntax),
sometime it will return S_OK, but the changes will not saved, as it
was described in my first message.

But all work fine when I list all records from current or
Word::wdFirstDataSourceRecord to required record with
Word::wdNextDataSourceRecord. It is not fast way when I should modify
only one record from 1000, but it work!!!
 

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