Thanks, Mario
I’ve come a long way since I asked the questions
-
SKIPIF: thanks for making clear that it won’t work. I can work around it by removing the record and the SKIPIF merge field.
-
From the examples I have run it seems that most of the IFs in our existing templates works well enough. I’ll keep an eye out for large blocks, but I suspect they’re not block-level in the GemBox sense and so will be fine.
If I hit something I can’t handle I’ll come back and ask a separate question. -
Catalog
The use case is this:
I have a database that in some cases stores tab-separated .csv data file (flat data file) and header source (the merge field names) and a .doc template.
They are the audit trail of the documents that were sent out so they need to be accessible. For example invoices.
Our programs allow each invoice in an invoice run to be opened separately, and that means mail merging with a data range.
The documents are stored this way because it saved space. One copy of the template file + all the merge data takes up less space than storing a copy of every finished .doc file separately.
(but that really doesn’t matter. They are there, and I have to deal with them)
Some of these stored documents are Catalog merges.
Note: this is the (very old) .doc mail merge that has existed “forever”. I’ve seen it used with Word 97 but it is older than that.
If you open the Mail Merge Helper dialog you see this:
In the screen shot you can see that the setting for Main document Merge Type says “Catalog”. That changes the behaviour so that all records are listed on the same page (only breaking page when it runs out of space).
The other main choice is “Merge Letter”, and that setting would give you a page per record in the data line.
The result of a Catalog merge would be the same as you’d get in GemBox if you had a DataSet data source with a header and a details table, with one (dummy) header record and our (flat) data file as the details table - all detail records related to the one header record.
So that’s what I’ve done. Read in the existing data file (tweak it a bit to add the merge field names as the first record), set up a DataSet as described, read in the template .doc, and – to make it work - programmatically add RangeStart: and RangeEnd: fields to the template document structure (first section and last section).
And it works!
(luckily I know precisely which templates are meant to be catalog and which are letter)
It would be nice if I did not have to tweak the data and add the fields. But at least I have a method that’ll work.
I can’t send a Visual Studio project. I do not work in C# natively, but in another language that has .Net support.
I can give you some idea of the contents of the files and the result but I’ll put them in separate replies. Apparently I’m a “new user” and not allowed to attach more than one image
Regards
Karin