Thursday, December 23, 2010

SharePoint 2010 Site Templates Document Library Workflow + OneNote

I ran across a strange problem today. Here's my situation. Saving a site as a site template (wsp solution), the site had a document library that had a default template of a OneNote file and it also had workflow associated with it (created with SPD). Using the site template to recreate the file works but the document library's "New Document" button was disabled and there was no template associated with it in the new site.

I wrote a bit of code that resets the document library to use the OneNote document as its template but the question remains, why did that button get greyed out when a workflow was associated with that document library and saved in the template.

I tested saving the template without the workflow associated with the document library and the OneNote template stayed associated with the document library, it was only when I associated a workflow with the document library that the "New Document" button got greyed out.

Bug!

Monday, December 6, 2010

OneNote Publish to PDF

Microsoft.Office.Interop.OneNote Publish. To publish the entire notebook, use the code below, where Personal is the name and folder of my notebook. The Publish action will find all the .one files and combine them into one pdf file. Whammooo!!

var onenoteApp = new Microsoft.Office.Interop.OneNote.Application();

string bstrHierarchyID = string.Empty;
onenoteApp.OpenHierarchy(@"C:\Users\brad.test\Documents\OneNote Notebooks\Personal\",
System.String.Empty, out bstrHierarchyID, Microsoft.Office.Interop.OneNote.CreateFileType.cftNone);

string bstrTargetFilePath = "C:\\Temp\\Personal1.pdf";

onenoteApp.Publish(bstrHierarchyID, bstrTargetFilePath, OneNote.PublishFormat.pfPDF);