View Single Post
  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Checkboxes on mailmerge recipients list

Hi Steffen,

I knew there was a reason why I never manipulated .Included but I had
forgotten what it was. I get exactly the same thing here. I can't think of a
way around it - even performing a merge to a new document does not magically
create the .included objects.

You can trap the error when you test .Included. I suppose that is enough to
tell you that all the records must be included (because the user has not
looked at the Recipients dialog box) but I can't see how you can get Word to
create these objects without showing the dialog.

I will see if I can find out anything more about this.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Steffen Grellmann" wrote in message
...
Hi Peter,

thank you for replying.

My main problem at that point is that I can't read the value of
.Included without an error message in that case, that a new connection
to the data source has been freshly established /and/ Word's
recipients list has not been opened by clicking the appropriate button
on the command bar at minimum once! Any suggestions? I don't want to
solve this by opening the recipients list per code
(Dialogs(wdDialogMailMergeRecipients).Show). Setting the
SetAllErrorFlags and SetAllIncludedFlags even do not solve this
behaviour.

Sub x()
Dim lLastRecord As Long
With ActiveDocument.MailMerge.DataSource
.ActiveRecord = wdLastDataSourceRecord
lLastRecord = .ActiveRecord
.ActiveRecord = wdFirstDataSourceRecord
Debug.Print CStr(.ActiveRecord) & ": " & CStr(.Included)
Do Until .ActiveRecord = lLastRecord
.ActiveRecord = wdNextDataSourceRecord
Debug.Print CStr(.ActiveRecord) & ": " & CStr(.Included)
Loop
End With
End Sub


Thanks for that snippet. This is quite helpful because .RecordCount
always returns -1 when "SELECT DISTINCT..." is used (which I have to
use for some special reasons...). And .LastRecord is returning a
negative value in some cases!

But I can't remember which version of Word first had
wdLastDataSourceRecord
etc.


Word 97 definetly don't have the wdLastDataSourceRecord, relying on
some articles, Word 2000 and newer has (not tested).

Ther may also be problems in a
multi-user environment if someone adds or deletes records while you
iterate
through them (I really do not know what Word does in that case)/


I will do some tests on this as soon as it is clear that my plan to
use the Checkstate on my own form can be realized.

Although you can /set/ .ActiveRecord to the special values like
wdLastDataSourceRecord , you can't compare .ActiveRecord to them because
in
that case VBA thinks you are trying to compare .ActiveRecord with a
negative
integer.


But this doesn't matter if I would use your snippet above which is
using the value of .LastRecord instead of .RecordCount, which I would
normally use in For...Next constructs, or I'm wrong?

Personally, I think this confusion of actual numeric values and
symbolic values is a very poor way to do things.

ACK!

Kind regards,

Steffen