Office Development with Visual Studio

Develop Office Business Applications using Visual Studio

December, 2009

Posts
  • Office Development with Visual Studio

    Migrating an Outlook Solution to .NET Framework 4 in Visual Studio 2010 (Norm Estabrook)

    • 0 Comments

    Visual Studio can help migrate your Outlook solutions from .NET Framework 3.5 to the .NET Framework 4. However, you still have to do a few things manually to make it all work. 

    Beth Massi converts an Outlook Solution that targets the .NET Framework 3.5 to an Outlook Solution that targets the .NET Framework 4 client profile in this very cool and informative blog entry - Migrating an Outlook Client to .NET Framework 4 in Visual Studio 2010.

  • Office Development with Visual Studio

    Making a Custom Group Appear in the Message Tab of a Mail Item (Norm Estabrook)

    • 1 Comments

    You can add a custom group to the Message tab of an Outlook mail item.  For example, here is a custom group named "MyCoolGroup" that I added to the message tab of a new message:

    image

    Outlook lets you open a message in the following two modes:

    • Compose (you are drafting a new message).
    • Read (you are reading a message). 

    Making a custom group appear for only one of these modes is pretty easy.  Making it appear for both modes is a tad more challenging. That is because the control ID of the Message tab in read mode is different than the control ID of the Message tab in compose mode. When you design your custom group in the VSTO Ribbon designer, you can only specify one control ID. This means that when you run the project, the custom group will only appear in the Message tab of a compose window or the Message tab of a read window depending on which control ID you specify at design-time.

    If you want the group to appear in both versions of the Message tab (read and compose), you have to do a bit more work. Here is how you make the group appear for both modes:

    First, add a Ribbon (Visual Designer) to an Outlook 2007 add-in project.

    Then, set the RibbonType property of the Ribbon to Microsoft.Outlook.Mail.Read as follows:

    image

    On the Ribbon designer, add a group to a tab and customize the group as desired. 

    On the Ribbon designer, select the tab, open the Properties window, and then set the OfficeId of the tab to TabReadMessageTabReadMessage is the control ID of the default tab that appears on the Ribbon of a mail message that is open in read mode. 

    image

    Ok. Now when you run the project, your custom group will appear only if you open a mail item in read mode. Now you need to add second Ribbon to your project to display this custom group in a mail item that is open in compose mode.

    Add a second Ribbon (Visual Designer) to the project. Then, set the RibbonType property of the Ribbon to Microsoft.Outlook.Mail.Compose as follows:

    image

    On the Ribbon designer, select the tab of the second Ribbon, open the Properties window, and then set the OfficeId of the tab to TabNewMailMessageTabNewMailMessage is the control ID of the default tab that appears on the Ribbon of a mail message that is open in compose mode. 

    I know what your thinking. Do you mean I have to create two separate custom groups? That defeats the whole point of trying to do this right?  Yes that would. Fortunately, you don’t have to create two custom groups. You only have to create two Ribbons as I have shown here. You can use the same custom group in both Ribbons.  Here is how:

    Open the first Ribbon that you created in the Ribbon Designer.  In the Ribbon Designer, select your custom group. In the Properties window, set the Modifiers property of the group to Public.

    Open the code file of the second Ribbon that you created (called Ribbon2 in my project).

    In the constructor of the second Ribbon, add the custom group from Ribbon1 to Ribbon2 as follows:

    public Ribbon2()
    {
        InitializeComponent();
        Ribbon1 firstRibbon = new Ribbon1();
        this.tab1.Groups.Add(firstRibbon.group1);
    }

    You can read more about adding custom groups to built-in tabs in the following MSDN articles:

    How to: Customize a Built-in tab

    How to: Get Started Customizing the Ribbon

    Ribbon Designer

    Customizing a Ribbon for Outlook

  • Office Development with Visual Studio

    Office Development with Visual Studio 2008 Tutorial Series – Part 2(Beth Massi)

    • 0 Comments

    Last month Robert Green, VSTO MVP, started a series of tutorials on building on Office 2007. Today we published part 2 of his step-by-step tutorials.

    In this second part of the series of tutorials on Office Business Applications, learn how to create a Word 2007 price quote generation solution using Visual Studio 2008. This tutorial shows you how to create a custom task pane to display data from a database and binding that data to content controls. This step-by-step tutorial also includes full source code in Visual Basic and C#. Check out the tutorial on the VSTO Developer Center:

    Building an Office Business Application Part 2 – Generating Automobile Quotes

    And if you missed part 1:

    Building an Office Business Application Part 1 - Scheduling Customer Appointments

    If you’re just getting started with Office development in Visual Studio, this is a great place to start.

    Enjoy,
    -Beth Massi, Visual Studio Community

  • Office Development with Visual Studio

    Using Office 2010 Extensibility Schemas with VSTO addins for Beta 2 (Stephen Peters)

    • 0 Comments

    Office 2010 brings in many new features to the Ribbon and Backstage extensibility. In order to take advantage of those changes in VSTO addins, you will need to update your ribbon XML projects to use the new Office 2010 schema.

    First, you will need to see if the schema is installed. To do this, look in “C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas\1033” (you might need to modify this to point to your Visual Studio installation directory). If customui14.xsd is there, you can skip ahead to the next paragraph. Otherwise download the schema from here, and install it in the directory above. When you are done, double check to make sure that the custom14ui.xsd file is there.

    Go to the Ribbon XML item that you want to use on Office 2010. For this blog post I am going to use a Word 2010 addin with a single Ribbon XML item, but the same code can work with any VSTO project with only minor modifications.

    At the top Ribbon1.xml, there is a line

      <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">

    You will want to replace the URL with

      http://schemas.microsoft.com/office/2009/07/customui

    If you look in the properties window for the XML document, the schema for the document should now point to the customui14.xsd that was installed. Now we can play around with it a bit. Under </ribbon> in Ribbon1.xml, add the following code:

      <backstage>
        <tab id="VSTOTab" label="VSTO Tab" insertAfterMso="TabInfo">
          <firstColumn>
            <group id="VSTOGroup" label="Hello From VSTO!">
              <topItems>
                <button id="AddMoreCowbell"
                  label="Add More Cowbell"
                  onAction="AddMoreCowbell" />
              </topItems>
            </group>
          </firstColumn>
        </tab>
      </backstage>
    

    We will also need to add the callback to Ribbon1.cs:

    public void AddMoreCowbell(Office.IRibbonControl control)
    {
        System.Windows.Forms.MessageBox.Show("Fever Cured");
    }

    And, of course, the integration in ThisAddin.cs

    protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
    {
        return new Ribbon1();
    }

    Run your add-in, and when you go to the backstage, you will find the backstage tab that we just added:

    clip_image002

    Now that you have the schemas set up, you can read up more on extending Backstage and new Ribbon features here:

    Microsoft Office 2010 Technical Articles

        - Customizing the Office 2010 Backstage View for Developers

        - Ribbon Extensibility in Office 2010: Tab Activation and Auto-Scaling

    Office 2010 Custom UI Schema (repost from above)

  • Office Development with Visual Studio

    New Learning Resources on the VSTO Developer Center (Beth Massi)

    • 2 Comments

    Last week we revamped the Learn pages on the VSTO Developer Center with more content that allows you to pivot on more fine-grained topics and tasks under each type of Office solution. We’ve changed the layout of these pages so that you can browse for a type of solution (right now we have Excel, Word, Outlook and Deployment) and then you can drill down into the specific topics to reveal articles and videos underneath. As you select a topic on the left, the content changes on the right so check it out.

    image

    We’ve gone through and picked key content in the Visual Studio and Office MSDN libraries, other Developer Centers and blogs like this one to bring you a better integrated learning experience -- especially if you’re just getting started programming Office solutions with Visual Studio. Let me know what topics I’ve missed by making a comment to the end of this post or by contacting me directly and I’ll get them added. Also let me know how you like this layout, we’re planning on taking this approach to the Visual Basic and C# Developer Centers as well.

    This is a work in progress so you’ll see more content being added to the site as I find it.  I suggest making the VSTO Developer Center your home page so you don’t miss a beat ;-).

    Enjoy,
    -Beth Massi, Visual Studio Community

Page 1 of 1 (5 items)