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  

How to reference a field's te once if duplicated in successive rec



 
 
Thread Tools Display Modes
  #1  
Old May 9th, 2005, 06:14 PM
Frustrated
external usenet poster
 
Posts: n/a
Default How to reference a field's te once if duplicated in successive rec

Hi,

I'd like to use the field "country" as a title for a list of organizations
from that specific country, and have it update the title only when a new
country is encountered. I'm using a catalog merge, but cannot figure out how
to get the country, such as "USA" to print only once over the list of
organizations, and then print a new country title when encountered during the
merge.

I've tried using a bookmark reference and the "if - then -else" field, but
have not figured out a solution.

Can somebody help?

Thanks in advance...
  #2  
Old May 10th, 2005, 09:10 AM
Doug Robbins
external usenet poster
 
Posts: n/a
Default

This macro run on the catalog may do what you want:

' Macro to create multiple items per condition in separate tables from a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i


--
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
"Frustrated" wrote in message
...
Hi,

I'd like to use the field "country" as a title for a list of organizations
from that specific country, and have it update the title only when a new
country is encountered. I'm using a catalog merge, but cannot figure out
how
to get the country, such as "USA" to print only once over the list of
organizations, and then print a new country title when encountered during
the
merge.

I've tried using a bookmark reference and the "if - then -else" field, but
have not figured out a solution.

Can somebody help?

Thanks in advance...



  #3  
Old May 10th, 2005, 02:52 PM
Frustrated
external usenet poster
 
Posts: n/a
Default

Wow...thanks! I will try this out and get back to the listserv

"Doug Robbins" wrote:

This macro run on the catalog may do what you want:

' Macro to create multiple items per condition in separate tables from a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i


--
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
"Frustrated" wrote in message
...
Hi,

I'd like to use the field "country" as a title for a list of organizations
from that specific country, and have it update the title only when a new
country is encountered. I'm using a catalog merge, but cannot figure out
how
to get the country, such as "USA" to print only once over the list of
organizations, and then print a new country title when encountered during
the
merge.

I've tried using a bookmark reference and the "if - then -else" field, but
have not figured out a solution.

Can somebody help?

Thanks in advance...




  #4  
Old May 10th, 2005, 06:11 PM
Frustrated
external usenet poster
 
Posts: n/a
Default

Hi Doug,

I tried the macro, but there was a "compilation error" at the "set ttab = "
line. Couldn't figure out what to do from there!

Thanks again,

"Frustrated"

Wow...thanks! I will try this out and get back to the listserv

"Doug Robbins" wrote:

This macro run on the catalog may do what you want:

' Macro to create multiple items per condition in separate tables from a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i


--
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
"Frustrated" wrote in message
...
Hi,

I'd like to use the field "country" as a title for a list of organizations
from that specific country, and have it update the title only when a new
country is encountered. I'm using a catalog merge, but cannot figure out
how
to get the country, such as "USA" to print only once over the list of
organizations, and then print a new country title when encountered during
the
merge.

I've tried using a bookmark reference and the "if - then -else" field, but
have not figured out a solution.

Can somebody help?

Thanks in advance...




  #5  
Old May 10th, 2005, 09:55 PM
Doug Robbins
external usenet poster
 
Posts: n/a
Default

The following needs to all on one line

Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)

The email program inserts line breaks that you will need to remove in the
visual basic editor

--
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
"Frustrated" wrote in message
...
Hi Doug,

I tried the macro, but there was a "compilation error" at the "set ttab =
"
line. Couldn't figure out what to do from there!

Thanks again,

"Frustrated"

Wow...thanks! I will try this out and get back to the listserv

"Doug Robbins" wrote:

This macro run on the catalog may do what you want:

' Macro to create multiple items per condition in separate tables from
a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As
Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i


--
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
"Frustrated" wrote in message
...
Hi,

I'd like to use the field "country" as a title for a list of
organizations
from that specific country, and have it update the title only when a
new
country is encountered. I'm using a catalog merge, but cannot figure
out
how
to get the country, such as "USA" to print only once over the list of
organizations, and then print a new country title when encountered
during
the
merge.

I've tried using a bookmark reference and the "if - then -else"
field, but
have not figured out a solution.

Can somebody help?

Thanks in advance...





 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using calculated fields in multiple queries Linguist Running & Setting Up Queries 6 May 27th, 2005 02:09 PM
Additional fields for form based parameter query/null fields geeksdoitbetter Running & Setting Up Queries 2 January 7th, 2005 10:05 PM
Populate fields in Form Header based on header fields in startup f Pat Dools Using Forms 0 January 7th, 2005 03:19 PM
Selecting Fields for Update Steve Daigler Page Layout 4 October 15th, 2004 02:13 PM
Setting axis limits by reference to fields Geoff Charts and Charting 2 November 5th, 2003 05:57 PM


All times are GMT +1. The time now is 08:14 PM.


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