Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graywolf Graywolf is offline
external usenet poster
 
Posts: 22
Default Automate opening a merge with Mailmerge Recipients open

I'm trying to automate a Word Mailmerge using VB6. I have an interface built
that allows the user to pick the type of document and I have basic
datasources defined for each document. In this specific example I'm doing a
merge for mailing labels. However, the end user needs to further refine who
gets a mailing label and who doesn't. I have built into the interface the
ability to pick and choose from the original query list the people who should
get a label. I can then change the underlying query before opening the Word
document. However, I can't seem to get the Word document to behave properly
and display my narrowed down list of recipients. All I can get to come up is
the full list (as if I never changed the underlying query). It appears that
if I alter the datasource in any way, then the merge breaks. So now what I
would like to do is just bring up the merge document with the full list of
recipients and have the "Merge Recipients" window open so the end user can
refine their list from Word instead of from my interface. How do I get the
merge to open with the "Merge Recipients" window opened up?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graywolf Graywolf is offline
external usenet poster
 
Posts: 22
Default Automate opening a merge with Mailmerge Recipients open

I'm having trouble getting things posted properly. My issue has actually been
posted twice. Please see and respond to my post for "Automate opening a merge
with Mailmerge Recipients open". And I'm using Word 2003 SP3, NOT Word 97.

"Graywolf" wrote:

I'm trying to automate a Word Mailmerge using VB6. I have an interface built
that allows the user to pick the type of document and I have basic
datasources defined for each document. In this specific example I'm doing a
merge for mailing labels. However, the end user needs to further refine who
gets a mailing label and who doesn't. I have built into the interface the
ability to pick and choose from the original query list the people who should
get a label. I can then change the underlying query before opening the Word
document. However, I can't seem to get the Word document to behave properly
and display my narrowed down list of recipients. All I can get to come up is
the full list (as if I never changed the underlying query). It appears that
if I alter the datasource in any way, then the merge breaks. So now what I
would like to do is just bring up the merge document with the full list of
recipients and have the "Merge Recipients" window open so the end user can
refine their list from Word instead of from my interface. How do I get the
merge to open with the "Merge Recipients" window opened up?

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Automate opening a merge with Mailmerge Recipients open

I'm having trouble getting things posted properly. My issue has
actually been
posted twice.


A lot of people seem to have been experiencing difficulties with the
web-based interface. But please bear in mind that you are not talking to
Microsoft here - most of the people who answer questions are volunteers.

How are you trying to modify the query before opening the Word document?
Are you using e.g. an Access data source and actually modifying the
Access query code, for example? Or are you actually setting Word's
Mailmerge.Datasource.Querystring property?

What you may find is tht you actually have no option but to disconnect
the existing data source and use MailMerge.OpenDatasource to open it
again, with the query you need.

Peter Jamieson

http://tips.pjmsn.me.uk

Graywolf wrote:
I'm having trouble getting things posted properly. My issue has actually been
posted twice. Please see and respond to my post for "Automate opening a merge
with Mailmerge Recipients open". And I'm using Word 2003 SP3, NOT Word 97.

"Graywolf" wrote:

I'm trying to automate a Word Mailmerge using VB6. I have an interface built
that allows the user to pick the type of document and I have basic
datasources defined for each document. In this specific example I'm doing a
merge for mailing labels. However, the end user needs to further refine who
gets a mailing label and who doesn't. I have built into the interface the
ability to pick and choose from the original query list the people who should
get a label. I can then change the underlying query before opening the Word
document. However, I can't seem to get the Word document to behave properly
and display my narrowed down list of recipients. All I can get to come up is
the full list (as if I never changed the underlying query). It appears that
if I alter the datasource in any way, then the merge breaks. So now what I
would like to do is just bring up the merge document with the full list of
recipients and have the "Merge Recipients" window open so the end user can
refine their list from Word instead of from my interface. How do I get the
merge to open with the "Merge Recipients" window opened up?

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graywolf Graywolf is offline
external usenet poster
 
Posts: 22
Default Automate opening a merge with Mailmerge Recipients open

Thanks for responding Peter. I realize that you guys are volunteers, but a
lot of you have 'MVP' behind your name and you guys obviously know a lot more
than I do.
I tried using the querystring property of mailmerge and everytime I did I
seemed to lose the links to the fields. i.e. I would have to match fields
again in the merge document because all my original field mapping was lost
when the sql statement changed (even though the table and fields did not
change, only which records are selected for output). My most recent attempt
at getting this to work was to alter the underlying Access query. I open
Access through DAO and actually change the querydef in Access, save the
change, then open the Word merge document that's still pointing to the
datasource linked to the query, only now the query has been changed. This
seems to work a little better, because I don't seem to lose the field
mappings, but I'm still having problems getting the correct output.

How do you disconnect the datasource? and if I do, won't I lose my field
mappings again? and if I lose my field mappings, how do I reconstruct them
programmatically?
I wouldn't think this should be so difficult, what am I doing wrong? Do you
need to see a section of my VB6 code?

"Peter Jamieson" wrote:

I'm having trouble getting things posted properly. My issue has

actually been
posted twice.


A lot of people seem to have been experiencing difficulties with the
web-based interface. But please bear in mind that you are not talking to
Microsoft here - most of the people who answer questions are volunteers.

How are you trying to modify the query before opening the Word document?
Are you using e.g. an Access data source and actually modifying the
Access query code, for example? Or are you actually setting Word's
Mailmerge.Datasource.Querystring property?

What you may find is tht you actually have no option but to disconnect
the existing data source and use MailMerge.OpenDatasource to open it
again, with the query you need.

Peter Jamieson

http://tips.pjmsn.me.uk

Graywolf wrote:
I'm having trouble getting things posted properly. My issue has actually been
posted twice. Please see and respond to my post for "Automate opening a merge
with Mailmerge Recipients open". And I'm using Word 2003 SP3, NOT Word 97.

"Graywolf" wrote:

I'm trying to automate a Word Mailmerge using VB6. I have an interface built
that allows the user to pick the type of document and I have basic
datasources defined for each document. In this specific example I'm doing a
merge for mailing labels. However, the end user needs to further refine who
gets a mailing label and who doesn't. I have built into the interface the
ability to pick and choose from the original query list the people who should
get a label. I can then change the underlying query before opening the Word
document. However, I can't seem to get the Word document to behave properly
and display my narrowed down list of recipients. All I can get to come up is
the full list (as if I never changed the underlying query). It appears that
if I alter the datasource in any way, then the merge breaks. So now what I
would like to do is just bring up the merge document with the full list of
recipients and have the "Merge Recipients" window open so the end user can
refine their list from Word instead of from my interface. How do I get the
merge to open with the "Merge Recipients" window opened up?


  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Automate opening a merge with Mailmerge Recipients open

To disconnect the data source, change the type of document from a mailmerge
document to a normal Word document and then change it back to the desired
type of mail merge main document. The merge fields will still be in the
document.

As far as the "field mapping" is concerned, if by that it can be implied
that you are not using the actual names of the fields from the data source,
then it would be far better if you did use the data source field names
directly as then no mapping would be required.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Graywolf" wrote in message
...
Thanks for responding Peter. I realize that you guys are volunteers, but a
lot of you have 'MVP' behind your name and you guys obviously know a lot
more
than I do.
I tried using the querystring property of mailmerge and everytime I did I
seemed to lose the links to the fields. i.e. I would have to match fields
again in the merge document because all my original field mapping was lost
when the sql statement changed (even though the table and fields did not
change, only which records are selected for output). My most recent
attempt
at getting this to work was to alter the underlying Access query. I open
Access through DAO and actually change the querydef in Access, save the
change, then open the Word merge document that's still pointing to the
datasource linked to the query, only now the query has been changed. This
seems to work a little better, because I don't seem to lose the field
mappings, but I'm still having problems getting the correct output.

How do you disconnect the datasource? and if I do, won't I lose my field
mappings again? and if I lose my field mappings, how do I reconstruct them
programmatically?
I wouldn't think this should be so difficult, what am I doing wrong? Do
you
need to see a section of my VB6 code?

"Peter Jamieson" wrote:

I'm having trouble getting things posted properly. My issue has

actually been
posted twice.


A lot of people seem to have been experiencing difficulties with the
web-based interface. But please bear in mind that you are not talking to
Microsoft here - most of the people who answer questions are volunteers.

How are you trying to modify the query before opening the Word document?
Are you using e.g. an Access data source and actually modifying the
Access query code, for example? Or are you actually setting Word's
Mailmerge.Datasource.Querystring property?

What you may find is tht you actually have no option but to disconnect
the existing data source and use MailMerge.OpenDatasource to open it
again, with the query you need.

Peter Jamieson

http://tips.pjmsn.me.uk

Graywolf wrote:
I'm having trouble getting things posted properly. My issue has
actually been
posted twice. Please see and respond to my post for "Automate opening a
merge
with Mailmerge Recipients open". And I'm using Word 2003 SP3, NOT Word
97.

"Graywolf" wrote:

I'm trying to automate a Word Mailmerge using VB6. I have an interface
built
that allows the user to pick the type of document and I have basic
datasources defined for each document. In this specific example I'm
doing a
merge for mailing labels. However, the end user needs to further
refine who
gets a mailing label and who doesn't. I have built into the interface
the
ability to pick and choose from the original query list the people who
should
get a label. I can then change the underlying query before opening
the Word
document. However, I can't seem to get the Word document to behave
properly
and display my narrowed down list of recipients. All I can get to come
up is
the full list (as if I never changed the underlying query). It appears
that
if I alter the datasource in any way, then the merge breaks. So now
what I
would like to do is just bring up the merge document with the full
list of
recipients and have the "Merge Recipients" window open so the end user
can
refine their list from Word instead of from my interface. How do I get
the
merge to open with the "Merge Recipients" window opened up?





  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Automate opening a merge with Mailmerge Recipients open

Yes, if you disconnect, you will lose the mappings.

You only need the mappings if
a. the field names vary from data source to data source and you do not
want to "fix up" the MERGEFIELD field names in your mail merge main
document and/or
b. you (or your users) are using ADDRESSBLOCK or GREETINGLINE fields

In case (a), to do your own mappings, you obviously have to have some
way to decide which "database field name" should be mapped to any given
"address field name", but as long as you have that...

how do I reconstruct them
programmatically?


....use e.g. the Activedocument.Mailmerge.Datasource.MappedDataFiel ds
collection once you have set up a datasource.

This collection is unusual - compared to other collections in the Word
object model - in that it has 30 predefined members - you cannot add new
ones, and the main (only?) thing you do to existing ones is assign a
value to the DataFieldIndex.

Each member corresponds to a predefined "Address field name" such as
"City" (whose index is wdCity, value 12). So suppose you have a
"database" field in your data source called "Location" that you want to
assign to the address field "City". Then you can either do something
like the following:

Dim objDS As Word.MailMergeDataSource
Dim objDSDF As Word.MailMergeDataField
Dim objDSFN As Word.MailMergeFieldName
Dim objMDFs As Word.MappedDataFields
Dim objMM As Word.MailMerge
Set objMM = ActiveDocument.MailMerge
Set objDS = objMM.DataSource
Set objMDFs = objMMDS.MappedDataFields

' This assumes that you know that
' the "Location" field exists
' What is more, this is the "mangled" name
' if for example, you have Excel column names
' longer than 40 characters, Word will create
' unique 40-character names.
' Excel column names with hyphens will have
' the hyphen removed.
' Excel column names with spaces will have
' underscores instead of spaces
' and so on...I certanly do not know all
' the rules.
' You need to use the exact mangled name

objMDFs(wdCity).DataFieldIndex = objMMDS.DataFields("Location").Index

More likely, you will want to do something like loop through all the
DataField names and decide which name to assign to which
MappedDataField. But I leave that to you.

If that's what you're already doing and it doesn't work, yes, let's see
the code.

I realize that you guys are volunteers, but a
lot of you have 'MVP' behind your name and you guys obviously know a

lot more
than I do.


BTW my main point here was intended to be "don't expect an immediate
reply" as there isn't 24/7 coverage :-)


Peter Jamieson

http://tips.pjmsn.me.uk

Graywolf wrote:
Thanks for responding Peter. I realize that you guys are volunteers, but a
lot of you have 'MVP' behind your name and you guys obviously know a lot more
than I do.
I tried using the querystring property of mailmerge and everytime I did I
seemed to lose the links to the fields. i.e. I would have to match fields
again in the merge document because all my original field mapping was lost
when the sql statement changed (even though the table and fields did not
change, only which records are selected for output). My most recent attempt
at getting this to work was to alter the underlying Access query. I open
Access through DAO and actually change the querydef in Access, save the
change, then open the Word merge document that's still pointing to the
datasource linked to the query, only now the query has been changed. This
seems to work a little better, because I don't seem to lose the field
mappings, but I'm still having problems getting the correct output.

How do you disconnect the datasource? and if I do, won't I lose my field
mappings again? and if I lose my field mappings, how do I reconstruct them
programmatically?
I wouldn't think this should be so difficult, what am I doing wrong? Do you
need to see a section of my VB6 code?

"Peter Jamieson" wrote:

I'm having trouble getting things posted properly. My issue has

actually been
posted twice.


A lot of people seem to have been experiencing difficulties with the
web-based interface. But please bear in mind that you are not talking to
Microsoft here - most of the people who answer questions are volunteers.

How are you trying to modify the query before opening the Word document?
Are you using e.g. an Access data source and actually modifying the
Access query code, for example? Or are you actually setting Word's
Mailmerge.Datasource.Querystring property?

What you may find is tht you actually have no option but to disconnect
the existing data source and use MailMerge.OpenDatasource to open it
again, with the query you need.

Peter Jamieson

http://tips.pjmsn.me.uk

Graywolf wrote:
I'm having trouble getting things posted properly. My issue has actually been
posted twice. Please see and respond to my post for "Automate opening a merge
with Mailmerge Recipients open". And I'm using Word 2003 SP3, NOT Word 97.

"Graywolf" wrote:

I'm trying to automate a Word Mailmerge using VB6. I have an interface built
that allows the user to pick the type of document and I have basic
datasources defined for each document. In this specific example I'm doing a
merge for mailing labels. However, the end user needs to further refine who
gets a mailing label and who doesn't. I have built into the interface the
ability to pick and choose from the original query list the people who should
get a label. I can then change the underlying query before opening the Word
document. However, I can't seem to get the Word document to behave properly
and display my narrowed down list of recipients. All I can get to come up is
the full list (as if I never changed the underlying query). It appears that
if I alter the datasource in any way, then the merge breaks. So now what I
would like to do is just bring up the merge document with the full list of
recipients and have the "Merge Recipients" window open so the end user can
refine their list from Word instead of from my interface. How do I get the
merge to open with the "Merge Recipients" window opened up?

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
How do I automate opening the properties box on save? Luke Microsoft Word Help 1 February 12th 09 02:19 PM
How do I automate opening the properties box on save? Luke Microsoft Word Help 0 February 12th 09 12:48 PM
how can I change recipients details in a merge recipients list Barry Mailmerge 2 February 16th 08 08:54 AM
Use VBA to auto open Mail Merge Recipients on opening doc Nucleo Mailmerge 2 August 18th 05 11:03 AM


All times are GMT +1. The time now is 02:34 PM.

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"