Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Steffen Grellmann Steffen Grellmann is offline
external usenet poster
 
Posts: 7
Default Checkboxes on mailmerge recipients list

Hi newsgroup,

I'm quite familiar how Word is handling SELECT-statements.

What I want to do is to programmatically access/set the state of the
checkboxes in the "mailmerge recipients list" in order to set that
state on my own Word form (which includes a similar recipients list).

How is Word reaching that unchecked items are not printed when
executing the mail merge?

Could someone bring more light on this, please?
Your time and help is higly appreciated.

Kind regards,

Steffen
  #2   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

Roughly speaking the checked/unchecked states of these boxes correspond to
the value of ActiveDocument.MailMerge.DataSource.Included for the
ActiveRecord.

In other words, if you want to set or examine the checkbox value, you have
to navigate to the record you want then examine or modify the value of
..Included.

However,
a. it isn't particularly easy to manipulate the .ActiveRecord reliably, in
the general case (the facilities for doing this are a bit weird, and if you
do it one way, you'll find that when you iterate through the records, you
will not even see the ones where Included is set to False)
b. my recent tests in this area have tended to hang Word.

--
Peter Jamieson
http://tips.pjmsn.me.uk

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

I'm quite familiar how Word is handling SELECT-statements.

What I want to do is to programmatically access/set the state of the
checkboxes in the "mailmerge recipients list" in order to set that
state on my own Word form (which includes a similar recipients list).

How is Word reaching that unchecked items are not printed when
executing the mail merge?

Could someone bring more light on this, please?
Your time and help is higly appreciated.

Kind regards,

Steffen


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Steffen Grellmann Steffen Grellmann is offline
external usenet poster
 
Posts: 7
Default Checkboxes on mailmerge recipients list

Hi Peter,

thank you for replying.

On Wed, 12 Dec 2007 09:18:49 -0000, "Peter Jamieson"
wrote:

Roughly speaking the checked/unchecked states of these boxes correspond to
the value of ActiveDocument.MailMerge.DataSource.Included for the
ActiveRecord.


This was exactly what I wanted to know for getting started on this
matter. Thank you!

I just want to give you a short response before I'm getting deeper
into it.

In other words, if you want to set or examine the checkbox value, you have
to navigate to the record you want then examine or modify the value of
.Included.


OK, I have checked this but it's not working that simple as it is
described in the F1 help.

However,
a. it isn't particularly easy to manipulate the .ActiveRecord reliably, in
the general case (the facilities for doing this are a bit weird, and if you
do it one way, you'll find that when you iterate through the records, you
will not even see the ones where Included is set to False)


It seems tricky and buggy. I will do some more testing and give you an
response.

b. my recent tests in this area have tended to hang Word.

ACK!

Kind regards,

Steffen
  #4   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

You probably need something like the following:

---------------------------------------------
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
---------------------------------------------

But I can't remember which version of Word first had wdLastDataSourceRecord
etc. You also need to consider the possibility that with some data sources,
Word may not actually be able to determine the number of the last record
without reading the entire data source, e.g. if the data source is an OLE DB
source with a "forward only cursor". 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)/

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. Personally, I think this confusion of actual numeric values and
symbolic values is a very poor way to do things.
--
Peter Jamieson
http://tips.pjmsn.me.uk

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

thank you for replying.

On Wed, 12 Dec 2007 09:18:49 -0000, "Peter Jamieson"
wrote:

Roughly speaking the checked/unchecked states of these boxes correspond to
the value of ActiveDocument.MailMerge.DataSource.Included for the
ActiveRecord.


This was exactly what I wanted to know for getting started on this
matter. Thank you!

I just want to give you a short response before I'm getting deeper
into it.

In other words, if you want to set or examine the checkbox value, you have
to navigate to the record you want then examine or modify the value of
.Included.


OK, I have checked this but it's not working that simple as it is
described in the F1 help.

However,
a. it isn't particularly easy to manipulate the .ActiveRecord reliably,
in
the general case (the facilities for doing this are a bit weird, and if
you
do it one way, you'll find that when you iterate through the records, you
will not even see the ones where Included is set to False)


It seems tricky and buggy. I will do some more testing and give you an
response.

b. my recent tests in this area have tended to hang Word.

ACK!

Kind regards,

Steffen


  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Steffen Grellmann Steffen Grellmann is offline
external usenet poster
 
Posts: 7
Default Checkboxes on mailmerge recipients list

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


  #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


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mailmerge recipients yshridhar Mailmerge 0 July 18th 07 10:02 AM
How do I make a list of people from an *.mdb recipients list Vicki Mailmerge 17 May 20th 06 01:44 PM
can't add to recipients list LJ Rea Mailmerge 2 February 1st 06 04:54 AM
Printing a list of recipients from a mail merge list Kathryn at GJS Microsoft Word Help 1 March 9th 05 04:34 PM
Mailmerge Recipients doesn't work with SQL Server Gelatinous_Blob Mailmerge 2 December 17th 04 05:34 PM


All times are GMT +1. The time now is 04:51 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"