Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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. |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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. |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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. |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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. |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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. |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
email merge with multiple recipients in "To", "CC" & "BCC" | Mailmerge | |||
How do I change page range "All" to "current Pages" in print menu | Microsoft Word Help | |||
Automated Mail Merge "Now Printing Page " Boxes | Mailmerge | |||
"Conditional formatting" in Word drop-down form fields | Microsoft Word Help | |||
Mail Merge - Fields missing within "insert merge field" tab | Mailmerge |