A common situation is to prepare invoices, etc. from information in a database. Clients usually have extremely customized invoice formats, but the data to be filled in is basically the same. This article and its related code present a new (I have searched, but could not find anything related to this topic, so I believe it’s new), innovative, and productive way of producing dynamic Office documents. I am using the word Office in this entire document as it does not relate solely to Microsoft Office. I have tested this approach on Open Office as well, and it works. The associated code enables to perform Token Replacement on both Office products.

Again, due to a larger community available at CodeProject, this article together with its Source Code is available if full at:

http://www.codeproject.com/KB/office/OfficeTokenReplacement.aspx

The Code for the article is also attached below.

UPDATE:

  •  (Feb 24, 2010) – Fixed a minor bug in replacement of header/footer sections.