For an internal project, I made an InfoPath to WordML converter in Sharepoint. For our case, project references are filled in InfoPath. Sharepoint translates the XML InfoPath documents to XML Word (WordML) documents so they can be used in the Sharepoint proposal accelerator. A nice example of Sharepoint Office integration and business innovation. Let's say..be more productive! ;)
Sharepoint WebPart
To do the conversion, I made a simple webpart that picks up the InfoPath documents from a form library, applies an XSLT to them and put them back into a target library in Sharepoint.

Yes, it’s the Dutch version of Sharepoint Portal Server :)
To be honest, the code is not that exciting. So, let’s take a look:
SPWeb aWeb = SPControl.GetContextWeb(Context);
aWeb.AllowUnsafeUpdates = true;
SPListCollection myCollection = aWeb.Lists;
myCollection.IncludeRootFolder = true;
// Source and Target library
SPList WordMLList = myCollection[ddlTarget.SelectedItem.Value];
SPList InfoPathList = myCollection[ddlSource.SelectedItem.Value];
// Loop through the files
foreach (SPListItem myItem in InfoPathList.Items)
{
SPFile myFile = myItem.File;
Stream myStream = new MemoryStream(myFile.OpenBinary());
XmlDocument myDoc = new XmlDocument();
myDoc.Load(myStream);
XmlDocument newDoc = new XmlDocument();
XslTransform xslt = new XslTransform();
string strXSLT = "/_layouts/Office/InfoPath2WordML.xslt";
xslt.Load(HttpContext.Current.Server.MapPath(strXSLT));
// Apply XSLT
newDoc.Load(xslt.Transform(
myDoc.CreateNavigator(),
null,
new XmlUrlResolver()
));
// Add WordML header
StringBuilder myString = new StringBuilder();
myString.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><?mso-application progid=\"Word.Document\"?>");
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(myString.ToString() + newDoc.InnerXml);
SPFileCollection files = WordMLList.RootFolder.Files;
string newUrl = files.Folder.Url + "/" + myFile.Name;
// Save file to target library
files.Add(newUrl, bytes, true);
}
Proposal Accelerator
Once we’ve converted the documents into WordML documents, we can use it in the Office Proposal Accelerator. This accelerator is provided by Microsoft to enable productivity when writing proposal documents. The accelerator searches through the WordML documents using an Office Task Pane add-on. With a single click the documents can be inserted into the proposal.
What else?
So, what else? The InfoPath project reference can be used in many ways. Using XSLT conversions can be made, but with some more imagination, also other ‘information containers’ can be provided:
- Portfolio items in MCMS for a website (cool, my next project??)
- Proposals
- Project Sites in Sharepoint
- Project data in SQL Server
- Etc.
So, this kind of is a higher level of Office productivity and innovation integrating different applications and tools in Sharepoint.