Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lüko Willms Lüko Willms is offline
external usenet poster
 
Posts: 13
Default Conditional page eject in "Catalogue" mail merge


I have a mailmerge of type "catalogue" and want to insert a page
eject when a certain field changes. How do I do that?

Let's say, this controlling field is called "Zimmer_Nr", as German
for Room_No.

I haven't done Winword programming for at least half a year and
can't remember how to do it, but I would need it for tomorrow...

MS-Office 2000, data source is an Excel sheet.

I was thinking to insert a mailmerge IF ... ELSE before the first
item in the data row, comparing the actual value of the mailmerge
field "Zimmer_Nr" to a DOCVARIABLE, and assign the current value of
the "Zimmer_Nr" to a DOCVARIABLE at the end of the data row.

Or can I access the field value indexed by the MERGESEQ value?

Yours,
L.W.

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Conditional page eject in "Catalogue" mail merge


I was thinking to insert a mailmerge IF ... ELSE before the first
item in the data row, comparing the actual value of the mailmerge
field "Zimmer_Nr" to a DOCVARIABLE, and assign the current value of
the "Zimmer_Nr" to a DOCVARIABLE at the end of the data row.


That is what you have to do but you can't set a DOCVARIABLE from a field so
you have to use SET and REF fields

e.g. put the following at the beginning of your document

{ IF { MERGESEQ } = 1 "{ SET previousZimmer_Nr "{ MERGEFIELD
"Zimmer_Nr" }" }" "" }

Then at the point where you want the page break

{ IF "{ MERGEFIELD "Zimmer_Nr" }" = "{ REF previousZimmer_Nr }" "" "put a
hard page break character here" }{ SET previousZimmer_Nr "{ MERGEFIELD
"Zimmer_Nr" }" }

All the {} need to be the special field braces you can insert using ctrl-F9.
You can probably get rid of a few of the double-quotes, especially if
Zimmer_Nr is always numeric.

A minor problem when using { MERGESEQ } is that it's not set to the current
record number when you preview, only when you actually merge, so the preview
does not necessarily work how you might expect.

Alternatively, if you are executing the merge from VBA, you can consider
using MailMerge events and directly altering the Mail Merge Main Document
when you detect a change in Zimmer_Nr

Peter Jamieson
"Lüko Willms" wrote in message
...

I have a mailmerge of type "catalogue" and want to insert a page
eject when a certain field changes. How do I do that?

Let's say, this controlling field is called "Zimmer_Nr", as German
for Room_No.

I haven't done Winword programming for at least half a year and
can't remember how to do it, but I would need it for tomorrow...

MS-Office 2000, data source is an Excel sheet.

I was thinking to insert a mailmerge IF ... ELSE before the first
item in the data row, comparing the actual value of the mailmerge
field "Zimmer_Nr" to a DOCVARIABLE, and assign the current value of
the "Zimmer_Nr" to a DOCVARIABLE at the end of the data row.

Or can I access the field value indexed by the MERGESEQ value?

Yours,
L.W.


  #3   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 Conditional page eject in "Catalogue" mail merge

The following macro will separate a catalog type mailmerge into separate
tables when the data in the first field changes.

' 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

"Lüko Willms" wrote in message
...

I have a mailmerge of type "catalogue" and want to insert a page
eject when a certain field changes. How do I do that?

Let's say, this controlling field is called "Zimmer_Nr", as German
for Room_No.

I haven't done Winword programming for at least half a year and
can't remember how to do it, but I would need it for tomorrow...

MS-Office 2000, data source is an Excel sheet.

I was thinking to insert a mailmerge IF ... ELSE before the first
item in the data row, comparing the actual value of the mailmerge
field "Zimmer_Nr" to a DOCVARIABLE, and assign the current value of
the "Zimmer_Nr" to a DOCVARIABLE at the end of the data row.

Or can I access the field value indexed by the MERGESEQ value?

Yours,
L.W.



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lüko Willms Lüko Willms is offline
external usenet poster
 
Posts: 13
Default Conditional page eject in "Catalogue" mail merge

Am Tue, 15 May 2007 07:30:53 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

Thanks a lot for your help, and thanks too to Doug Robbins.

Then at the point where you want the page break

{ IF "{ MERGEFIELD "Zimmer_Nr" }" = "{ REF previousZimmer_Nr }" "" "put a
hard page break character here" }{ SET previousZimmer_Nr "{ MERGEFIELD
"Zimmer_Nr" }" }


I have chosen your approach because it seemed to be easier than
writing a whole VBA program, and because it was more like what I was
looking for. It works OK, but the "hard page break charakter" does
break the field -- there may not be a paragraph or page break within a
mail merge field. I had a similar problem already last year with
another project then.

I tried to insert an {AUTOTEXT NewPage} with NewPage being a blank,
but with a paragraph formatting forcing a page break before the
paragraph. That did not work either. I have now inserted "###" as a
special sequence of characters which I then change later to something
else with the paragraph formatting as mentioned above. That did work.


Cheers,
L.W.



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Conditional page eject in "Catalogue" mail merge

Well, it sounds as if you have what you need anyway, but...

It works OK, but the "hard page break charakter" does
break the field -- there may not be a paragraph or page break within a
mail merge field.


....I'm not sure what you mean here, because you can certainly insert a page
break and the field works as expected. Of course the second part of the
field code disappears onto the next page, but that's about it. What does not
work (or do you mean that for other reasons you do not want a page break
inside a field) ?

Peter Jamieson

"Lüko Willms" wrote in message
...
Am Tue, 15 May 2007 07:30:53 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

Thanks a lot for your help, and thanks too to Doug Robbins.

Then at the point where you want the page break

{ IF "{ MERGEFIELD "Zimmer_Nr" }" = "{ REF previousZimmer_Nr }" "" "put
a
hard page break character here" }{ SET previousZimmer_Nr "{ MERGEFIELD
"Zimmer_Nr" }" }


I have chosen your approach because it seemed to be easier than
writing a whole VBA program, and because it was more like what I was
looking for. It works OK, but the "hard page break charakter" does
break the field -- there may not be a paragraph or page break within a
mail merge field. I had a similar problem already last year with
another project then.

I tried to insert an {AUTOTEXT NewPage} with NewPage being a blank,
but with a paragraph formatting forcing a page break before the
paragraph. That did not work either. I have now inserted "###" as a
special sequence of characters which I then change later to something
else with the paragraph formatting as mentioned above. That did work.


Cheers,
L.W.






  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lüko Willms Lüko Willms is offline
external usenet poster
 
Posts: 13
Default Conditional page eject in "Catalogue" mail merge

Am Tue, 15 May 2007 15:16:42 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

It works OK, but the "hard page break charakter" does
break the field -- there may not be a paragraph or page break within a
mail merge field.


...I'm not sure what you mean here, because you can certainly insert a page
break and the field works as expected.


It didn't work for me. I used the "Insert" menu, item "Manual break"
(my retranslation from German), chosing "page break". That didn't
work. I had a similar problem last year with a paragraph mark in a
mailmerge field. The processing of the field would end at those hard
marks, either paragraph or page. When I replaced the paragraph mark
with the line brea (SHIFT-ENTER), then it worked.


Yours,
L.W.


  #7   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 Conditional page eject in "Catalogue" mail merge

Try Ctrl+Enter

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

"Lüko Willms" wrote in message
...
Am Tue, 15 May 2007 15:16:42 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

It works OK, but the "hard page break charakter" does
break the field -- there may not be a paragraph or page break within a
mail merge field.


...I'm not sure what you mean here, because you can certainly insert a
page
break and the field works as expected.


It didn't work for me. I used the "Insert" menu, item "Manual break"
(my retranslation from German), chosing "page break". That didn't
work. I had a similar problem last year with a paragraph mark in a
mailmerge field. The processing of the field would end at those hard
marks, either paragraph or page. When I replaced the paragraph mark
with the line brea (SHIFT-ENTER), then it worked.


Yours,
L.W.




  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Conditional page eject in "Catalogue" mail merge

That's strange. I vaguely remember your query last year too.

If you want, despam my e-mail and send me a document where the problem shows
up, and I'll have a look. (remove "KillmapS"

Peter Jamieson

"Lüko Willms" wrote in message
...
Am Tue, 15 May 2007 15:16:42 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

It works OK, but the "hard page break charakter" does
break the field -- there may not be a paragraph or page break within a
mail merge field.


...I'm not sure what you mean here, because you can certainly insert a
page
break and the field works as expected.


It didn't work for me. I used the "Insert" menu, item "Manual break"
(my retranslation from German), chosing "page break". That didn't
work. I had a similar problem last year with a paragraph mark in a
mailmerge field. The processing of the field would end at those hard
marks, either paragraph or page. When I replaced the paragraph mark
with the line brea (SHIFT-ENTER), then it worked.


Yours,
L.W.



  #9   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lüko Willms Lüko Willms is offline
external usenet poster
 
Posts: 13
Default Conditional page eject in "Catalogue" mail merge

Am Wed, 16 May 2007 07:04:14 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

If you want, despam my e-mail and send me a document where the problem shows
up, and I'll have a look. (remove "KillmapS"


I can't send the mailmerge document I was working on ... but I could
try to produce one which shows the problem.

Anyway, I tried again Doug Robbin's suggestion to user the
CTRL-ENTER key combination, but that is only a shortcut to the same
form feed command.

Word simply stops processing the field when it encounters a New Page
or New Paragraph command. I had a new page for every record from the
data source.


Yours,
L.W.



  #10   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 Conditional page eject in "Catalogue" mail merge

Sounds to me like it would be simpler to just run a macro over the document
produced be executing the merge.

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

"Lüko Willms" wrote in message
...
Am Wed, 16 May 2007 07:04:14 UTC, schrieb "Peter Jamieson"
auf
microsoft.public.word.mailmerge.fields :

If you want, despam my e-mail and send me a document where the problem
shows
up, and I'll have a look. (remove "KillmapS"


I can't send the mailmerge document I was working on ... but I could
try to produce one which shows the problem.

Anyway, I tried again Doug Robbin's suggestion to user the
CTRL-ENTER key combination, but that is only a shortcut to the same
form feed command.

Word simply stops processing the field when it encounters a New Page
or New Paragraph command. I had a new page for every record from the
data source.


Yours,
L.W.





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
email merge with multiple recipients in "To", "CC" & "BCC" Raghu Mailmerge 6 April 21st 23 12:58 PM
How do I change page range "All" to "current Pages" in print menu Shiv Microsoft Word Help 1 May 4th 07 01:13 PM
Automated Mail Merge "Now Printing Page " Boxes ksg Mailmerge 1 January 12th 07 06:25 PM
"Conditional formatting" in Word drop-down form fields Benjamin Microsoft Word Help 2 September 8th 06 12:33 PM
Mail Merge - Fields missing within "insert merge field" tab jenniclair Mailmerge 7 August 31st 06 11:55 AM


All times are GMT +1. The time now is 08:07 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"