A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Merging to A, B,C...



 
 
Thread Tools Display Modes
  #1  
Old September 4th, 2009, 02:47 PM posted to microsoft.public.word.mailmerge.fields
Michael Koerner
external usenet poster
 
Posts: 2,341
Default Merging to A, B,C...

I have no problem setting up my merge from Excel to Word onto an Envelope
for all the names I have in the spread sheet. What I would like to be able
to do is merge where it uses the first letter of the Last Name and be able
to merge where all records begin with A, then again for B and so on.

Or even the ability to select say 50 records, then records 51-100, then
101-150 and so on. Any help greatly appreciated. I'm using XP and Office
2007

--

Regards
Michael Koerner



  #2  
Old September 5th, 2009, 08:16 AM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Merging to A, B,C...

Some clarification please: can we assume that you know how to select
either the As (may be possible in the Query options facility, or you
might be able to add a SKIPIF field to your mail merge main document
that does something like

{ SKIPIF { MERGEFIELD "Last Name" } = "A*" }

then change the A to B, B to C to do each batch) or the record numbers?
If so, is it the automation part you want, i.e. you want to be able to
merge batch A (or 1-100), then, as a separate step, batch B, without
having to change the selection criteria?

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
I have no problem setting up my merge from Excel to Word onto an Envelope
for all the names I have in the spread sheet. What I would like to be able
to do is merge where it uses the first letter of the Last Name and be able
to merge where all records begin with A, then again for B and so on.

Or even the ability to select say 50 records, then records 51-100, then
101-150 and so on. Any help greatly appreciated. I'm using XP and Office
2007

  #3  
Old September 5th, 2009, 08:00 PM posted to microsoft.public.word.mailmerge.fields
Michael Koerner
external usenet poster
 
Posts: 2,341
Default Merging to A, B,C...

Peter;

Thanks very much what you posted is what I'm looking for only I don't know
how to use what you posted.

The second part was to select the records in 100 record increments to create
the merge documents. Different than selecting from the Alpha characters.

--

Regards
Michael Koerner


"Peter Jamieson" wrote in message
...
Some clarification please: can we assume that you know how to select
either the As (may be possible in the Query options facility, or you
might be able to add a SKIPIF field to your mail merge main document
that does something like

{ SKIPIF { MERGEFIELD "Last Name" } = "A*" }

then change the A to B, B to C to do each batch) or the record numbers?
If so, is it the automation part you want, i.e. you want to be able to
merge batch A (or 1-100), then, as a separate step, batch B, without
having to change the selection criteria?

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
I have no problem setting up my merge from Excel to Word onto an Envelope
for all the names I have in the spread sheet. What I would like to be able
to do is merge where it uses the first letter of the Last Name and be able
to merge where all records begin with A, then again for B and so on.

Or even the ability to select say 50 records, then records 51-100, then
101-150 and so on. Any help greatly appreciated. I'm using XP and Office
2007




  #4  
Old September 5th, 2009, 11:52 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Merging to A, B,C...

Can only get back to this in a day or two.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

Thanks very much what you posted is what I'm looking for only I don't know
how to use what you posted.

The second part was to select the records in 100 record increments to create
the merge documents. Different than selecting from the Alpha characters.

  #5  
Old September 6th, 2009, 10:36 AM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Merging to A, B,C...

You can try a macro like

Sub OneMergePerInitialLetter()
' error trapping to be added
Dim iLetter As Integer
Dim objMMMD As Word.Document
dim strSheetName As String
dim strColumnName
' Set this to the name of the worksheet or to the range name
strSheetName = "Sheet1$"

' Set this to the exact name of the column containing the name
' (upper/lower case is probably significant
strColumnName = "mycolumn"

Set objMMMD = ActiveDocument
With objMMMD
For iLetter = Asc("A") To Asc("Z")
.MailMerge.DataSource.QueryString = _
" SELECT * FROM [Sheet1$]" & _
" WHERE ucase(t) like '" & Chr(iLetter) & "%'"
With .MailMerge
' remove or change this as necessary
.Destination = wdSendToNewDocument
.Execute Pause:=False
End With
If MsgBox("Completed Letter " & Chr(iLetter) & _
". Do the next letter?", vbOKCancel) = vbCancel Then
Exit For
End If
Next
End With
Set objMMMD = Nothing
End Sub

See e.g. Graham Mayor's page at
http://www.gmayor.com/installing_macro.htm
if you need help on installing and running macros.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

Thanks very much what you posted is what I'm looking for only I don't know
how to use what you posted.

The second part was to select the records in 100 record increments to create
the merge documents. Different than selecting from the Alpha characters.

  #6  
Old September 6th, 2009, 02:40 PM posted to microsoft.public.word.mailmerge.fields
Michael Koerner
external usenet poster
 
Posts: 2,341
Default Merging to A, B,C...

Peter;

You macro to me looks like it is for a letter, will try it out, But, my need
is for envelopes, and has to have the following. this is taken from the
template file after it confirms the source of the data.

First Name Last Name
Address1
Address2
City Prov
Zip
Country

--

Regards
Michael Koerner


"Peter Jamieson" wrote in message
...
You can try a macro like

Sub OneMergePerInitialLetter()
' error trapping to be added
Dim iLetter As Integer
Dim objMMMD As Word.Document
dim strSheetName As String
dim strColumnName
' Set this to the name of the worksheet or to the range name
strSheetName = "Sheet1$"

' Set this to the exact name of the column containing the name
' (upper/lower case is probably significant
strColumnName = "mycolumn"

Set objMMMD = ActiveDocument
With objMMMD
For iLetter = Asc("A") To Asc("Z")
.MailMerge.DataSource.QueryString = _
" SELECT * FROM [Sheet1$]" & _
" WHERE ucase(t) like '" & Chr(iLetter) & "%'"
With .MailMerge
' remove or change this as necessary
.Destination = wdSendToNewDocument
.Execute Pause:=False
End With
If MsgBox("Completed Letter " & Chr(iLetter) & _
". Do the next letter?", vbOKCancel) = vbCancel Then
Exit For
End If
Next
End With
Set objMMMD = Nothing
End Sub

See e.g. Graham Mayor's page at
http://www.gmayor.com/installing_macro.htm
if you need help on installing and running macros.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

Thanks very much what you posted is what I'm looking for only I don't know
how to use what you posted.

The second part was to select the records in 100 record increments to
create
the merge documents. Different than selecting from the Alpha characters.



  #7  
Old September 6th, 2009, 04:05 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Merging to A, B,C...

Mine isn't really for any particular type of document - the reason the
word "letter" appears is because it's doing one merge for each letter of
the alphabet. But the macro does assume that you have your mail merge
main document set up, with all the fields that you need, and that you
have already made a connection to the data source.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

You macro to me looks like it is for a letter, will try it out, But, my need
is for envelopes, and has to have the following. this is taken from the
template file after it confirms the source of the data.

First Name Last Name
Address1
Address2
City Prov
Zip
Country

  #8  
Old September 6th, 2009, 07:19 PM posted to microsoft.public.word.mailmerge.fields
Michael Koerner
external usenet poster
 
Posts: 2,341
Default Merging to A, B,C...

Ahhhhhh! That shows you how much I know about macros g Will try it out,
thanks very much.

--

Regards
Michael Koerner


"Peter Jamieson" wrote in message
...
Mine isn't really for any particular type of document - the reason the
word "letter" appears is because it's doing one merge for each letter of
the alphabet. But the macro does assume that you have your mail merge
main document set up, with all the fields that you need, and that you
have already made a connection to the data source.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

You macro to me looks like it is for a letter, will try it out, But, my
need
is for envelopes, and has to have the following. this is taken from the
template file after it confirms the source of the data.

First Name Last Name
Address1
Address2
City Prov
Zip
Country



  #9  
Old September 8th, 2009, 01:22 PM posted to microsoft.public.word.mailmerge.fields
Michael Koerner
external usenet poster
 
Posts: 2,341
Default Merging to A, B,C...

Peter;

Tried you macro. Keep getting a Run-time error '4198' Command failed. I have
a hard time spelling macro, let alone editing them g

--

Regards
Michael Koerner


"Peter Jamieson" wrote in message
...
You can try a macro like

Sub OneMergePerInitialLetter()
' error trapping to be added
Dim iLetter As Integer
Dim objMMMD As Word.Document
dim strSheetName As String
dim strColumnName
' Set this to the name of the worksheet or to the range name
strSheetName = "Sheet1$"

' Set this to the exact name of the column containing the name
' (upper/lower case is probably significant
strColumnName = "mycolumn"

Set objMMMD = ActiveDocument
With objMMMD
For iLetter = Asc("A") To Asc("Z")
.MailMerge.DataSource.QueryString = _
" SELECT * FROM [Sheet1$]" & _
" WHERE ucase(t) like '" & Chr(iLetter) & "%'"
With .MailMerge
' remove or change this as necessary
.Destination = wdSendToNewDocument
.Execute Pause:=False
End With
If MsgBox("Completed Letter " & Chr(iLetter) & _
". Do the next letter?", vbOKCancel) = vbCancel Then
Exit For
End If
Next
End With
Set objMMMD = Nothing
End Sub

See e.g. Graham Mayor's page at
http://www.gmayor.com/installing_macro.htm
if you need help on installing and running macros.

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

Thanks very much what you posted is what I'm looking for only I don't know
how to use what you posted.

The second part was to select the records in 100 record increments to
create
the merge documents. Different than selecting from the Alpha characters.



  #10  
Old September 8th, 2009, 02:43 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Merging to A, B,C...

Sorry, I changed one part of it and not the other...

Change this statement

.MailMerge.DataSource.QueryString = _
" SELECT * FROM [Sheet1$]" & _
" WHERE ucase(t) like '" & Chr(iLetter) & "%'"

to

.MailMerge.DataSource.QueryString = _
" SELECT * FROM [" & strSheetName & "]" & _
" WHERE ucase(t) like '" & Chr(iLetter) & "%'"


As far as I can tell, it is this statement that is going wrong, so if
that does not fix the problem, it is possible that the sheet name that
you specify in the earlier line

strSheetName = "Sheet1$"

is not quite right. If the sheet name in the tab at the bottom of the
sheet in Excel is "Sheet1", you have to add a $ sign at the end and use

strSheetName = "Sheet1$"

not

strSheetName = "Sheet1"

If you are using a range name rather than a sheet name, /do not/ append
a $ sign.


Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

Michael Koerner wrote:
Peter;

Tried you macro. Keep getting a Run-time error '4198' Command failed. I have
a hard time spelling macro, let alone editing them g

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.