Random Technical Stuff RSS 2.0
 Friday, December 07, 2007

If you are like me you spend much of your time in the Office suite of applications, but as a developer or architect I used to rarely think about incorporating Office into my solutions.  I guess I spent too much time debugging Excel macros or struggling with the plumbing when I first starting playing with the Visual Studio Tools for Office (VSTO).  It seemed like more work that it was worth.  This was a shame because Office has some great advantages as a compliment to custom application development.

With the latest release of Office 2007 and Visual Studio 2008 the plumbing for extending the UI around Office applications has drastically improved.  I created the attached video (no audio on this one)  to show a quick example (7:34 to be exact) of how to create a Word add in.  In this example I take the following steps:

  • Create a new Word Add-In project
  • Add a Ribbon item to extend the Ribbon UI in Word
  • Modify the custom ribbon to name things friendly and add a toggle button
  • Add a User Control to hold my UI for my Task Pane
  • Modify the Add-In code to attach the user control to Word and create methods to show and hide the custom task pane
  • Write code behind the ribbon toggle button that calls the show and hide methods for the task pane
  • Run the application to show the extended ribbon user interface and how clicking on the custom toggle button shows and hides my user control
  • Adding some winforms controls to the user control and wiring them up to pull and push content from my user control to the document
  • Running the application again to show the user control in action reading content from the document and writing content back to the document

This is a fairly simplistic example, but enough to get started.  I have written some other demos that hook up the user control to a SQL Server database to populate form letters from customer data.  If you are interested in learning more, I'd suggest checking out the VSTO on MSDN.  One other thing - VSTO used to be a separate product that you needed to purchase on top of Visual Studio.  With VS 2008 Professional, VSTO is included right in the box.

Double click the video once it starts to see it full screen.  You can double click again on the full screen to go back to regular view.  If you are reading this in an RSS reader, you most likely need to go to the site to see the video.

 

This video was published via Silverlight Streaming

7-Dec-2007 6:05 PM  #    Comments
Office | Office Apps

 Tuesday, October 16, 2007

One of the newest features of Word 2007 and MOSS 2007 is a much tighter integration between the two applications, particularly when it comes to metadata.  There is a capability to integrate the metadata into the actual document rather than attach the metadata as an afterthought.  This example shows how to set this up.

Create a document library with the appropriate columns (attributes) you want to track.  In this case I have created document library called Features Requests with columns for tracking Description, Request Date, Status (choice of New, In Process, and Completed), and Priority (choice of High, Medium, and Low).

image

Bring up the Advanced Settings for the document library and click on the "Edit Template" link under the Document Template section.

image

and Word will open in the following fashion:

image

I created a quick shell document to capture the information required.

image

The attributes from MOSS become Document Properties that are exposed as Quick Parts in Word.  Word will respect the data types and try to infer the appropriate content control.  If the data type is a choice in MOSS, Word will create a drop down list.  For a date, Word will create a date picker.  One thing to note is that while I changed the column name for the Title to Description, the Quick Part still calls that data Title.

image

The fully laid out Word document will have the content controls embedded in the document itself and fully connected to the MOSS library.  You can change the properties of the content controls and nest them if you want to lock down certain sections of the document.

image

Now you can save the document and it will update the document template in the document library.  If you return to the document library and create a new document it will use the template that we linked to the document library.

image

As fields are filled in within the document the attributes change

image

As the document is saved back to the document library, all of the attributes are saved back to the columns in the document library.

image

The metadata about the document will fully round trip - if I change the metadata in MOSS, the document will change and vice versa.  If you want to understand the mechanics of this, you can crack open the document (save it locally, rename to use a .zip extension, and open it in explorer) and look at the custom xml folder.  The data is not embedded in the content of the document but is bound via custom xml.

16-Oct-2007 4:41 PM  #    Comments
MOSS | Office | Office Apps

Archive
<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
About the Author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Joe Shirey
All Content © 2008, Joe Shirey