Office Development with Visual Studio

Develop Office Business Applications using Visual Studio

April, 2008

Posts
  • Office Development with Visual Studio

    Feedback Requested for VS 2008 Service Pack 1 (Christin Boyd)

    • 11 Comments

    Have you used the new ClickOnce Publish and Deployment feature in Visual Studio 2008 for Office 2007 solutionsIf so, we need your feedback now - and we need it before May 8th (which is an internal deadline for our team)!  We're working on Service Pack 1 for Visual Studio 2008 and would like to know your opinion on a specific feature:

    <Start of current scenario:

    Currently the end-user is unable to cancel an Automatic Update most of the time.  When the user starts an Office application (e.g. Excel or Outlook) then the VSTO Runtime checks the registry to see if it's time to check for Addin Updates.  Then if it's time, it will go and download the ClickOnce Manifests (which is the .vsto and the .manifest files) from the deployment location.  If this process of downloading the manifests takes longer than 7 seconds, then the user is presented with a dialog that gives them the option to click Cancel, which halts the download.  Most of the time no one will see the Cancel because the downloading of the manifests is almost always faster than 7 seconds.

    If the user doesn't click Cancel, then the system makes a trust decision.  If the update is trusted, then it starts to download the actual assemblies.  While downloading the assemblies, the user is unable to work with the Office application.  They have to wait for the download to complete, the addin to get loaded, and then the user can start using the Office application.  Keep in mind that this process usually takes less than 20 seconds.

    If the user does click Cancel during the manifest download phase, then the side effect is that the addin is now DISABLED.  If the end user wants to re-enable the addin, then she needs to open Trust Center and go through about 3 clicks to enable it again.

    End of current scenario>

    So our question is, would you like to ALWAYS get the option to click Cancel during the process of downloading all the stuff?  Keep in mind that sometimes the whole process might be as short as 5 seconds, or as long as five minutes on sloooooow networks. 

    Next question for your feedback:  And then if you cancel, should we leave the existing "out of date version" of the Addin as Enabled? 

    The reason we disable the "out of date version" of the addin is because we received feedback from many companies saying that they want to enforce updates within the update time window.  Unfortunately we don't have the ability in Service Pack 1 to make the Enable/Disable feature a option for the developer (or IT department) to specify.  We're realizing that we have far more customers from companies who aren't as concerned about "enforcement" of updates.  Your feedback here and now will help us validate the needs of our customers.

    You will be happy to hear that we are planning to include lots of enable/disable and cancel options in the next version of Visual Studio.  Your feedback today will help us craft Service Pack 1 for Visual Studio 2008.

  • Office Development with Visual Studio

    OBA Sample Application Kits Release to Web! (Christin Boyd)

    • 2 Comments

    If you’re looking for guidance on how to integrate SAP or PeopleSoft into your Office applications, then the OBA Sample Application Kits are a great place to start. An OBA, or Office Business Application, is a composite application that integrates line-of-business systems with Office applications (e.g. Excel or Outlook) and Microsoft Office SharePoint Server (MOSS) 2007. These kits provide some great documentation and source code to help you get up and running quickly. The kits include:

    1. Source code for an end-to-end OBA
    2. Installation guide
    3. Solution walkthrough
    4. Technical overview document

    The kits are a free download and can be found by going to the OBA Sample Application Kits landing page on MSDN:

    http://msdn2.microsoft.com/en-us/office/cc442491.aspx

    Check out the kits and more by visiting the OBA Sample Application Kits site on MSDN today. Also, check out Steve Fox's blog for more information.

    -Christin Boyd, Program Manager

  • Office Development with Visual Studio

    Office development audio series 1 is now available (Harry Miller)

    • 2 Comments

    If you'd like a quick introduction to the main aspects of Office development using Visual Studio 2008 Professional, you can now get it while you drive, travel, exercise, eat lunch, or whenever you usually listen to your portable MP3 player. (Of course, you can also listen at your computer with your usual media player.) There are eight episodes that you can get individually or as a zipped group from this Microsoft Download Center page:

    Audio: Office Development Overview Series

    Portable media player Listen at your computer Listen on the go

    Each of the eight episodes is about five minutes long or less, and the whole series back-to-back lasts about 30 minutes. There's also a zipped file that contains transcripts for each episode.

    We have two more series planned for release in May that get deeper into details about Office development. Let us know what you think about these by leaving a comment on this post--we'd like to get your feedback.

  • Office Development with Visual Studio

    Databinding best practices for Excel (Christin Boyd)

    • 2 Comments

    I read a question on the forum about databinding in an Excel solution.  The developer was asking about Excel 2003, but the answer I wrote will work for both Excel 2003 and Excel 2007.  Here's the question:  http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3122341&SiteID=1&mode=1

    As a best practice you can create one dataset in ThisWorkbook designer and then programmatically reference it from your code in other sheets.

    Here’s how:

    Add new Data Source of Data Base type, by specifying a database connection and selecting tables, views and columns.

    Next open ThisWorkbook.vb in the designer.  It will look like it's a big gray box with two sentences that say "This is the workbook designer...."  Now from the Toolbox, under the Data section, select a DataSet and drag it onto the design surface.  When you drop it, you will get a dialog that asks if you want a typed or untyped dataset.  Select Typed.  It should prepopulate an edit box with <your namespace>.MyDataSet.  Click OK.  On the design surface you should now see an icon next to MyDataSet1.  In C# you will want to set the modifier to Internal or Public on the data set in the property browser.

    Next open the code behind ThisWorkbook.vb.  Inside the ThisWorkbook_Startup  procedure, you should fill your MyDataSet1 instance with code like this:

    VB Sample

      DimpatientAdapter As New MyDataSetTableAdapters.PatientsTableAdapter
      patientAdapter.Fill(Me.MyDataSet1.Patients) 

      Dim rxAdapter As New MyDataSetTableAdapters.PrescriptionsTableAdapter
      rxAdapter.Fill(Me.MyDataSet1.Prescriptions)

    C# sample

      MyDataSetTableAdapters.PatientsTableAdapter ta =
        new MyDataSetTableAdapters.PatientsTableAdapter();
      ta.Fill(myDataSet1.Patients);

    Next you can open Sheet1 designer.  Now select "Add New Data Source" from the data menu and this time choose to add an "Object" not a database!  You will get a dialog that shows the hierarchy and this time DO NOT select the table adapter!  Open the name of your project, then the namespace, then you should see MyDataSet. Select it then click OK.  This action will create an Object in your Data Sources window.

    Now you can select from the Data Sources Window, you should see something called MyDataSet.  This object can be used to create a databinding in your sheets.  So you can drag from this universal object into any one of your sheets.  Grab it and drag it onto Excel Sheet1 and it created an empty table. In order to finish setting it up, select the table and in the property grid click on the arrow next to DataMember property and select the data table that you want to be bound to the table. Try it, and see how it creates a new BindingSource object for each sheet, but you still have just the one DataSet instance. 

    In each Sheet, you need to add the following line of code for Each table:

      Me.PatientsDataTableBindingSource.DataSource = Globals.ThisWorkbook.MyDataSet1

    Please let me know through comments on this blog if this explanation works for you.  Thank you!

  • Office Development with Visual Studio

    Deploying an Office solution using Windows Installer (Mary Lee)

    • 7 Comments

    Visual Studio 2008 offers a ClickOnce deployment experience for solutions developed for the 2007 Microsoft Office system.  However, if you want to deploy additional files, add extra registry keys, or use SMS, you may still be interested in creating a Windows Installer package.

    Here are the very basic steps to configure your setup project:

    1. Add the release build or publish output of your solution. Then manually add the application and deployment manifests (.dll.manifest and .vsto files).

    2. For application-level projects, create the registry keys so that the Microsoft Office application can find your add-in. For more information, see Registry Entries for Application-Level Add-Ins. For the add-in name, use a syntax similar to [CompanyName].[AddinName].

    3. For document-level projects, update custom document properties which point to the location of the deployment manifest. If you leave the document in the same relative location compared to the customization assembly, you don't need to update the _AssemblyLocation property. But if you want to move the document to a user's desktop or Documents folders, you'll have to update the _AssemblyLocation property. For more information, see Custom Document Properties Overview.

    You must still use ClickOnce security to trust your solution. You can deploy your .msi at this point, but you'll see a trust prompt asking whether the solution should be installed or not. To avoid prompting your end users, sign your manifests with a known and trusted certificate or pre-trust the solution by creating an inclusion list entry. For more information, see Security in Office Solutions (2007 System).

    Bonus: there is sample code to help you complete the steps of deploying additional files, updating the document's _AssemblyLocation, and creating an inclusion list entry.  Visit http://code.msdn.microsoft.com/VSTO3MSI in the MSDN Code Gallery to download the sample code.

    For all the details, read the deployment whitepapers at Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 1 of 2) and Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 2 of 2).

    If you run into trouble implementing this, visit the VSTO MSDN forum at http://forums.microsoft.com/msdn/showforum.aspx?forumid=16&siteid=1 to search for answers or ask your questions. 

    Mary Lee, programming writer.

  • Office Development with Visual Studio

    Visual Studio Command Bar for Arranging Controls on Documents and Worksheets (McLean Schofield)

    • 2 Comments

    One of the lesser-known features of Visual Studio Tools for Office is the Microsoft Office Word and Microsoft Office Excel command bar. When you are developing a document-level project for Word or Excel (for example, a Word Document or Excel Workbook project) and you have the document or one of your worksheets open in the designer, this command bar appears in Visual Studio, just above the designer. In Excel, this command bar looks like the following by default.

    image 

    The first several buttons in this command bar are for changing the keyboard scheme and mapping XML to the document or worksheet. This post is about the purpose of the rest of the buttons.

    If you are designing a custom UI for your document or worksheet that includes Windows Forms controls that you add by using the designer, you can use these buttons to arrange the controls with a single click. When you select multiple controls in the designer, these buttons become enabled.

    image 

    From left to right, here are the buttons you can use:

    • Align Lefts. This button moves all of the controls to the left, so that they are aligned with the left side of the left-most control.

    • Align Centers. This button moves all of the controls left or right so that they are aligned around the vertical axis of the widest control.

    • Align Rights. This button moves all of the controls to the right, so that they are aligned with the right side of the right-most control.

    • Align Tops. This button moves all of the controls up, so that they are aligned with the top side of the upper-most control.

    • Align Middles. This button moves all of the controls up or down, so that they are aligned around the horizontal axis of the tallest control.

    • Align Bottoms. This button moves all of the controls down, so that they are aligned with the bottom side of the bottom-most control.

    • Make Horizontal Spacing Equal. The left-most and right-most control remain in place; the controls in between move horizontally so that there is equal horizontal space between each control.

    • Make Vertical Spacing Equal. The top-most and bottom-most control remain in place; the controls in between move vertically so that there is equal vertical space between each control.

    A special note about Word. In Word projects, the alignment buttons are enabled only if the selected controls are not in line with text. By default, controls that you add to a Word document at design time are in line with text. To change the layout style of the control, right-click the control and then click Format Control. Then, on the Layout tab, select a wrapping style other than In line with text:

    image

    Examples. Enough words! Here are some examples that show these alignment options in action. These examples are pretty contrived, but they should give you an idea of the effects of each option.

    Given the following buttons on a worksheet:

    image

    Align Lefts rearranges the controls as follows:

    image

    Align Centers rearranges the controls as follows:

    image

    And Align Rights rearranges the controls as follows:

    image

    Given the following buttons on a worksheet:

    image 

    Align Tops rearranges the controls as follows:

    image 

    Align Middles rearranges the controls as follows:

    image

    And Align Bottoms rearranges the controls as follows:

    image

    Given the following buttons on a worksheet:

    image

    Make Horizontal Spacing Equal rearranges the controls as follows:

    image

    Finally, given the following buttons on a worksheet:

    image 

    Make Vertical Spacing Equal rearranges the controls as follows:

    image 

    I hope these options come in handy then next time you are adding controls to a document or worksheet in VSTO.

    -------------------------------------------------

    McLean Schofield, Programming Writer

Page 1 of 1 (6 items)