Much Improved Approach for Automatic Document Generation using PowerTools


I am a newbie to PowerShell scripting.  This is probably pretty obvious to anyone who has taken a look at the PowerShell scripts that I've written.  Fortunately, there are people around who can improve on my efforts.

This blog is inactive.
New blog: EricWhite.com/blog

Blog TOC
Developer/Author Doug Finke has developed a much, much cleaner version of the PowerTools BulkMailing.ps1 script that generates multiple wordprocessing documents from a source XML file.  The best improvement is how the text of the document is specified in the script.  The document is specified by a 'here string', with embedded references to the properties of the object that is the source of the data for the document:

$letter = (@"
  Adventure Works
   437 Main Street
   Seattle, WA 98118
   $((Get-Date).ToString("D"))
  Customer ID: $($customer.CustomerID)

  $($customer.ContactName)
  $($customer.ContactTitle)
  $($customer.CompanyName)
  $($customer.Address)
  $($customer.City) , $($customer.Region) $($customer.PostalCode)

  $($customer.Country)


  Dear $($customer.ContactName) :

  Howard Snyder suggested that I get in touch with you regarding your document conversion needs.  Our company offers consulting services in the area of document transform.  We specialize in consulting using the Open XML SDK, the PowerTools for Open XML, and the OpenXML/ODF Translator.

  The Open XML SDK is a managed C# API published by Microsoft that makes it more convenient to work with Open XML.  The PowerTools for Open XML are an open source project at www.CodePlex.com/PowerTools.  They are an example of an approach to creation and modification of Open XML documents using PowerShell.
  The OpenXML/ODF Translator is an open source project on SourceForge.net.  We also work in the area of conversion of Open XML to HTML.  You may have a document repository that archives all documents authored by your employees.
  You may find it convenient to implement a solution that automatically ensures that all documents that are submitted to your repository are automatically converted to one or the other of either ODF or Open XML.  Or you may find it convenient to have all incoming email attachments of documents automatically converted to one or the other of the two formats.

  Or you may have a need to regularly convert a large repository of documents to HTML for easy access by employees using a browser.  I'll give you a call early next week to discuss.

  Sincerely,
  Tai Yee
  Account Manager
"@)

Even better, Doug has signed up to be a developer/contributor to the project.  His new, improved script is already available on www.CodePlex.com/PowerTools.  He has a lot of great ideas about how to improve the PowerTools, the most important being some ideas about better ways to move data into and out of documents (all three: word processing, spreadsheets, and presentation documents).

Welcome to the project, Doug!

This post introduces the PowerTools and includes a small screencast that shows how to build and use them.

Comments (3)
  1. Doug Mahugh says:

    Here are some interesting blog posts from the last week, as well as a few items I had missed while I

  2. Les quelques liens intéressants de la semaine pour vos projets Open XML : Technique : Custom XML : répéter

  3. Guido Leenders says:

    Hi Tai, we have a product (Invantive Composition) using the SDK for generating documents from within Microsoft Word (for end users). It is written using VSTO (not Powertools). We are currently enhancing it with features to allow importing data from Word documents into databases and webservices. During this process we have had (and to be honest: we are still sometimes having) problems with Word XML being "polluted" with many many tags (such as for revisions). We have a cleaning option now which removes clutter a lot; it also helps with translating Word documents because many tags are removed which don't have an influence on the translation. Are there any plans to add something like this to PowerTools too?

Comments are closed.

Skip to main content