Last week, the Visual Studio (VS) 2010 Beta 1 was released to the public. I’m personally very excited about the VS 2010 release because of the additional support for Office and SharePoint development. While you won’t see the SharePoint 2010 project templates in the Beta 1 release, you’ll find the legacy templates (remember VS Tools for Office 3.0?) that have persisted forward to this release which are present in the Beta 1 drop.

Note: If you have not downloaded the VS 2010 Beta 1 yet, you can get it here: http://www.microsoft.com/downloads/details.aspx?FamilyID=75cbcbcd-b0e8-40ea-adae-85714e8984e3&displaylang=en.

To install VS 2010 B1, I simply ran the install process (for the Professional SKU) and it installed fine (as an FYI, my laptop is a T61P with 4G RAM and Win 2008 Server, and is 32x). Goodness so far.

After you install VS 2010 B1, you can open it, choose File, New Project and then click on the Office tab to see what ships in the Beta 1 version of VS 2010. For the most part, you’ll see all of the 2007-centric templates that you had in VS 2008 for Office 2007 save for the SharePoint workflow templates.

image

I thought I would give the tools a test-run and create a Word 2007 document-level solution. To do this, I provided a name for my solution, browsed to a folder, and then clicked OK.

image

The experience was similar to the VS 2008 experience. That is, VS prompted me to either create a new document (you have a sub-set of the Word functionality available to you in the VS IDE so you can create and edit documents (or templates) directly within the IDE) or you can leverage an existing document. I chose the former and clicked OK.

image

The one thing I really like about VS 2010 is the new WPF-rendering of the IDE UI. It’s very slick. You can see below, that after I created the project here is the view of the project. To test out some controls, I dragged and dropped some Word content controls over to the Word document surface (they will be data containers for me later on). I prefer using these content controls because you can either data-bind directly to them or you can populate them from data pulled from web services or databases—which gets at the heart of why we build OBAs in the first place: integrate data directly into the information worker experience. Anyway, you can see here that the content controls have accessible properties that we can manipulate programmatically.

image

Here is a view of the Add Connection dialog—you’ll be familiar with this if you’ve added connections in VS 2008.

image

Adding a connection enabled me to add a Windows Form user control and then bind some data to the control—this is my proxy for what would normally be a web service call to a LOB system such as SAP, Siebel, Dynamics, and so on. You can see my last couple of posts where I’ve posted links to kits that provide you more detail here. (Note that you could also create a WPF user control and then use the Element Host to host the WPF on a WinForm user control. For the sake of expediency, I chose to use the WinForm.)

By default, the adding of a new connection and then dragging and dropping of the data onto a user control does not load the data on initialization, so you must add the following lines of code to the Recruitment_Load event.

private void Recruitment_Load(object sender, EventArgs e)
       {
           RecruitingDataSetTableAdapters.RecruitsTableAdapter adaptr = new TAPAirliftOBA.RecruitingDataSetTableAdapters.RecruitsTableAdapter();
          adaptr.Fill(this.recruitingDataSet.Recruits);

       }

image

The above is what the user control looks like.

You’ll see that I’ve added two events to test out the integration across the custom actions pane and SharePoint. The first will synchronize the text within the above fields with the content controls in the Word doc, and the update SharePoint button will take data from the Word document and update a SharePoint list. This is a nice way to begin to tie together information that you’re storing in an outside data source with document generation and SharePoint site data.

The code for the Sync Word event is simply assigning the Text property of the content controls to the appropriate fields that you’ve got displayed in the custom actions pane.

private void btnSyncWord_Click(object sender, EventArgs e)
{
    Globals.ThisDocument.wccHireeName.Text = recruitName;
    Globals.ThisDocument.wccPositionAppliedFor1.Text = positionAppliedFor;

    …

}

The code for the Update SharePoint event is listed below. The code uses the native Lists web service that ships with SharePoint 2007. A tip here is ensure you keep the Column names simple so you can ensure your CAML construct will adequately update the SharePoint list.

private void btnSyncSharePoint_Click(object sender, EventArgs e)
{
     startDate = Globals.ThisDocument.wccStartDate.Text;

     TAPAirliftOBA.MySPListService.Lists listService = new TAPAirliftOBA.MySPListService.Lists();
     listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
     listService.Url = "
http://mossvm/_vti_bin/Lists.asmx";

     System.Xml.XmlNode xmlListView = listService.GetListAndView("Hires", "");
     XmlDocument xmlDoc = new XmlDocument();
     XmlElement xmlElement = xmlDoc.CreateElement("Batch");
     xmlElement.InnerXml = "<Method ID='1' Cmd='New'><Field Name='Title'>" + recruitID + "</Field><Field Name='RecruitName'>" + recruitName + "</Field><Field Name='Position'>" + positionAppliedFor + "</Field>" + "<Field Name='StartDate'>" + startDate + "</Field>" + "</Method>";
     XmlNode xmlReturn = listService.UpdateListItems("Hires", xmlElement);
     System.Windows.MessageBox.Show("Information Added!");
}  

This will update a list in SharePoint as per the below.

image

This was a fairly straightforward example that illustrated how you could use the legacy support in Visual Studio 2010 Beta 1 to begin coding against the Office object model and integrate your Office customization with SharePoint. As I explore the Visual Studio Beta 1 tools a little more, I’ll post my findings with some additional code samples.

Happy coding!

Steve