Need Delphi code to programmatically create merge codes in Word and Excel (2007 or later), determine what merge codes are used in a Word/Excel template, and merge supplied data into these templates.
We need Delphi code that does the following:
1. ***SetUpMergeCodes*** procedure that programmatically creates Word and Excel toolbars/menu to give end users the option to insert merge codes into Word or Excel document templates. Parameters would include name for the Menu/toolbar and a list of the merge codes that should be available in each of several categories. We would generally need a menu with several main choices each of which have a dozen or more plain text items merge codes that could be inserted in the Word or Excel document. (e.g., Main areas might include items like, Job, Customer, Office; sub items for each would include items like Name, ID Number, Address, Home Phone, Cell Phone, etc. Programmatically defined merge codes would correspond to the items picked, e.g. , , etc.) This must all be controlled and set programmatically since the available menu options/merge codes will be different depending on the context and since new versions of our software could introduce new codes. (These merge codes would not be available to users in Word/Excel except when these programs were called by our program.)
2. ***GetMergeCodesUsed*** function that is passed the name of a Word or Excel template and that returns a list of merge codes present in that document so we know what data to gather to produce the document. This list of codes could be returned in a variant array, client data set, or delimited string.
3. ***MergeDocument*** function where we can pass the name of the document template and data (in cds or variant array) that corresponds to each of the merge codes (that is, to the codes retrieved with the *GetMergeCodesUsed* function described above). This function would merge the data provided into a copy of Word/Excel template passed, creating a new Word or Excel document with the data in place of the merge codes. Function would return the document created. (This document should be created in the temp folder.)
4. If some Word/Excel Add-on is needed to accomplish this that does not come with those programs, that that would be a part of this project as well.
5. Ability to have this functionality also work with Open Office would be a bonus, but is not essential.
These procedures/functions could be created in a bpl (preferred) or in a standard Delphi project. Code must work with Word and Excel 2007 and newer. All source code must be provided.
Windows XP - Windows 7