Office Development with Visual Studio

Develop Office Business Applications using Visual Studio

May, 2008

Posts
  • Office Development with Visual Studio

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

    • 1 Comments

    This series focuses on development tasks that are common as part of developing Office solutions, and describes the tools in Visual Studio 2008 that help you do these tasks quicker. The series is organized as short, five-minute episodes that you can listen to 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.) You can get all eleven episodes individually or as a zipped group from this Microsoft Download Center page:

    Audio: Office Development Developer Series

    Portable media player Listen at your computer Listen on the go

    There's also a zipped file that contains transcripts for each episode.

    Let us know what you think about these by leaving a comment on this post--we'd like to get your feedback.

    If you want to start with a broader overview, you can listen to the other two series:

    Audio: Office Development Overview Series
    Audio: Office Development Components Series

  • Office Development with Visual Studio

    Deploying Office Solutions with a Setup Project (Mary Lee)

    • 6 Comments

    You can now read the long awaited whitepapers about deploying Office 2007 solutions with a Visual Studio 2008 Setup project to create a Windows Installer package.  These whitepapers show you how to complete the following tasks:

    • Configure prerequisites: .NET Framework 3.5, the VSTO 3.0 runtime, and the Office primary interop assemblies.
    • Add the project output and manifests to the Setup project.
    • Create registry keys to load an application-level add-in.
    • Sign the solution with a known and trusted certificate, use the ClickOnce prompt, or create an inclusion list entry to grant trust to your solution.
    • Deploy additional components such as helper assemblies.
    • Update document-level solutions to separate the document and assembly in separate locations.
    • Use Windows Installer to install into the ClickOnce offline cache.
    • Modify the Setup project for Vista.

    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)

    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 have questions about the whitepapers, please visit the VSTO forum at http://social.msdn.microsoft.com/Forums/en-US/vsto/ to search for answers and ask your questions.

    Mary Lee, programming writer.

  • Office Development with Visual Studio

    Microsoft Office Developer Show Episode 2 (Harry Miller)

    • 3 Comments

    In this episode: a tip about how to save a new copy of a Word document instead of saving over the original, and how to create a class in an Outlook project to access methods without hitting the object model security prompts. Plus, Mary creates a quick data UI in Excel for her boss Kemp.

    Related resources for more information:

    Save a new copy of a document instead of saving over the original

    Create a class in an Outlook project to access methods without hitting the object model security prompts

    More about accessing Outlook from John R. Durant's blog

  • Office Development with Visual Studio

    Using VS 2008 to continue working on Office 2003 Add-ins (Anthony Crider)

    • 6 Comments

    Visual Studio 2008 allows a developer to create add-in projects that target Microsoft Office 2003 products even if Microsoft Office 2007 rather than Microsoft Office 2003 is installed.  So long as you don’t close and reopen the project, everything works fine. If you close the project and attempt to reopen it, however, you’ll be asked to upgrade the project.  Now, at first glance, this seems to be pretty unreasonable.  Moreover, Visual Studio’s Conversion Wizard would have you believe the project you are trying to open needs to be upgraded because the project targets a prior version of Visual Studio.  That's just confusing.  The Conversion Wizard is actually displaying canned text that it shows for any type of project conversion, for example an old C++ console application project from VS 2005.  The good news is that there is a way to fix your problem and let you continue working on your Office 2003 project.  In this blog post, I’ll walk through the problem, give you the way out, and then very briefly comment on the reasoning behind the upgrade solution and some of its quirks.

    Getting to the Problem

    Let's say you want to work on an Office 2003 solution in Visual Studio 2008.  Great!  Let's say that you also have Office 2007 installed.  You can start creating a new Office 2003 add-in using the New Project dialog, below, an Excel 2003 Add-in is being created.

    clip_image002

    When Visual Studio finishes creating the project, you’ll see something like the following:

    clip_image004

    Notice that in this case, there are a couple of warnings regarding the lack of registered primary interop assemblies for Microsoft Office Excel 2003.  In order to run and debug the project, I would need to install them on my system (and Office 2003 as well), but otherwise, creation of the project is successful and you can compile and deploy the project.

    The Problem

    But now, if you close and reopen the project, you’ll see the Visual Studio Conversion Wizard below.  That’s odd, you could create the project, compile it, deploy it, and maybe run and debug it (if the primary interop assemblies are installed and registered) but now you’re being asked to upgrade?  What’s going on here?

    clip_image006

    The answer is that when Visual Studio opens a project, it asks the project’s project system what it thinks about the state of the project.  If the project system thinks the project needs updating for any reason, the project system can reply to Visual Studio that an upgrade is required.  In this case, the Office Tools project system has decided that the project needs to be updated because the project targets a version of Office that is different from that installed.  Retargeting the Office version might be what you want, but in this case it isn’t.

    The Solution

    So how does one stop this behavior?  Well, that turns out to be pretty easy.  In Visual Studio’s Options dialog (Tools|Options), there is a category expander called Office Tools.  One of the items under this category is Project Upgrade.  After selecting the Project Upgrade item, you’ll be greeted by the Project Migration Scheme options dialog.  The very last option on this dialog is Always upgrade to installed version of Office.  And here is the problem.  Since it is currently checked (in the example below), the Office Tools project system will always signal to Visual Studio that an Office 2003 add-in needs to be upgraded if Office 2007 (or any other version of Office, for that matter) is installed.

    clip_image008

    Un-checking the option will solve the problem and Visual Studio will happily open the project without attempting to upgrade it first. If at some later time, you wish to upgrade the project to target a later version of Office, just re-check the option and the next time you try to open the project you’ll be greeted again by Visual Studio’s Conversion Wizard.

    The Problem in Sheep's Clothing

    For the preceding discussion, we talked only about what happens when you create a new add-in using Visual Studio 2008 that targets Office 2003.  What about add-ins that were created using Visual Studio 2005 and the Tools for Office Special Edition?  In this case, if you open the project, it must be upgraded to Visual Studio 2008.  At the same time, if the Always upgrade to installed version of Office option is checked, the Office target will be changed too.  If this is not the behavior that you want, make sure the option is unchecked and allow the upgrade to complete.  The project will be brought up to Visual Studio 2008, but the Office version will continue to target Office 2003.

    Some Commentary

    At the point where the Conversion Wizard is polling the project system regarding whether or not an upgrade is required, we are unable to offer a dialog box to you.  Otherwise, we would simply raise a Yes/No/Cancel dialog and allow you to select what behavior is appropriate for targeting the Office version.  While I could give you a long technical explanation of why we’re unable to pop up a dialog at that moment, let me say instead that our team honestly spent weeks hashing through this problem trying to find a better solution.  The short answer is that it would require significant architectural changes that were considered too risky.  After all, Visual Studio is a huge application, and we try very hard to mitigate risk and maintain high quality.  We’re still looking at this issue and possible architecture changes for the next version of Visual Studio.

    -Anthony Crider, Principal Software Developer

  • Office Development with Visual Studio

    Do you have an opinion about Visual Studio and .NET Framework developer Help content? (Kemp Brown)

    • 1 Comments

    Our Help content architect, Kathleen McGrath, has created a short, anonymous survey (15 questions/10 mins.) to gather input on how and when the Visual Studio and .NET Framework developer Help content is used, how satisfied you are with it, and   about areas that need improvement:

      Link to the Visual Studio and .NET Framework Developer Documentation Survey

    (Kathleen will also be taking this survey with her to TechEd in June.)

    The focus of this survey is content improvement. We want to learn more about the types of applications you're creating, the tools/technologies you're using, and how we can improve our content and code examples to help you achieve your goals.

    Thanks in advance for participating!

    - Kemp Brown, programming writer

  • Office Development with Visual Studio

    Microsoft Office Developer Show Episode 1 (Harry Miller)

    • 3 Comments

    This episode has a tip about adding controls to Word documents, a case file about how Canada Post solved its data entry problems, and what to do when an add-in doesn't run and there's no error message.

    Related resources for more information:

    Problem adding a label to a Word document

    Why did this add-in stop running?

    Canada Post case study

  • Office Development with Visual Studio

    Common Pitfalls during PIA Deployment and Installation (Mary Lee)

    • 41 Comments

    Deploying or installing the Office primary interop assemblies (PIAs) can sometimes be problematic. There are several common errors that occur when you try to deploy or install the PIAs.

    Deployment pitfalls

    A. Can I deploy the PIA DLL with my setup project?  Yes, you can include the PIA DLL in your setup project, but we recommend that you use the Primary Interop Assemblies for the 2007 Microsoft Office system redistributable file from the Microsoft Download Center.  this way, the installer copies the PIAs into the GAC, and also installs binding redirects.  The binding redirects ensure that the latest version of the PIAs on the computer are always loaded.  This is how a solution developed for Microsoft Office 2003 still works on the 2007 Microsoft Office system.

    Installation pitfalls

    A. Do you have administrator privileges? The account used to install the PIAs must have administrator privileges.

    B. Is the .NET Framework already installed? The computer must have a version of the .NET Framework installed (version 1.1, 2.0, 3.0, or 3.5) before the PIA installer is run. Windows XP does not include any version of the .NET Framework unless .NET 1.1 was downloaded from Windows Update. Windows Vista does include a version of the .NET Framework. When Microsoft Office is first installed, the .NET Framework installation is detected and the PIAs are automatically installed.

    C. Is Business Contact Manager installed? If Outlook 2007 with Business Contact Manager is already installed on the computer, you may see the following error message when you install the Primary Interop Assemblies for the 2007 Microsoft Office system from the Microsoft Download Center:

    Error 1316: Setup cannot read from file {PATH}\PIARedist.MSI. Check your connection to the network, or CD-ROM drive. For other potential solutions, see SETUP.CHM.

    Business Contact Manager for Outlook 2007 installs the PIAs by default, and the file name is PIARedist.MSI.  However, the file from the Microsoft Download Center is called o2007pia.msi.  When you install the PIAs from the Microsoft Download Center, this name conflict causes the 1316 error.

    The easiest thing to do here is to just ignore the error, because this message means that the PIAs are already installed. If you want to correct the error, uninstall the PIAs through the list of installed programs for the specific computer. Then you can reinstall the PIAs with the Primary Interop Assemblies for the 2007 Microsoft Office system from the Microsoft Download Center.

    I don't recommend that you follow the workaround posted at Error 1316 when installing Office 2007 PIA’s, which changes the name of the o2007pia.msi file to piaredist.msi and updates the product.xml to point to piaredist.msi.  If you change the name of the o2007pia.msi, anyone that installs the PIAs after you will experience the 1316 error.

    If you discover other PIA pitfalls, please feel free to leave a comment or question so I can update this entry.  Thanks for reading!

    Mary Lee, programming writer.

  • Office Development with Visual Studio

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

    • 1 Comments

    This series focuses on the main components or features of Visual Studio 2008 Professional that you can use for Office development. It's organized as short, five-minute episodes that you can listen to 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.) You can get all ten episodes individually or as a zipped group from this Microsoft Download Center page:

    Audio: Office Development Components Series

    Portable media player Listen at your computer Listen on the go

    There's also a zipped file that contains transcripts for each episode.

    We have one more series planned for release in the next few weeks that gets 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.

    If you want to start with a broader overview, you can listen to the series that we published a few weeks ago:

    Audio: Office Development Overview Series

  • Office Development with Visual Studio

    Peek at Service Pack 1 (Christin Boyd)

    • 3 Comments

    Visual Studio 2008 Service Pack 1 is not finished yet, but we do have a beta version of the documentation ready for you to read!  You can learn about some of the features that you'll see later this year when we release SP1. 

    I recommend starting with reading about a totally new feature that we put into SP1 that allows you to extend Word documents and Excel Workbooks at runtime from an Application-Level Add-in.  Here is the link to the Beta of the documentation:

    http://vs2008sp1docs.msdn.microsoft.com/en-us/ms334311.aspx

    You'll be able to create objects and respond to events including:

    • Host Controls
    • ListObjects
    • Smart Tags
    • Word Content Controls
    • and Events such as DocumentBeforeSave

    Only some of the new deployment features have been documented so far.  You can read about one of the new deployment features in the Event Logging (2007 System) page in the SP1 documentation here:

    http://vs2008sp1docs.msdn.microsoft.com/en-us/ms331997.aspx

    Starting in Visual Studio 2008 Service Pack 1 (SP1), you can use the event viewer in Windows to see error messages that are captured by the Visual Studio Tools for Office runtime when you install or uninstall Visual Studio Tools for Office solutions. You can use these messages from the event logger to resolve installation and deployment problems.

    The Beta version of the Service Pack is only getting distributed to about a thousand beta testers who have great reputations for submitting clear feedback and bug reports.  I hope this little peek at the documentation will get you excited about what's coming later this summer in Service Pack 1.

    -Christin Boyd, Program Manager

  • Office Development with Visual Studio

    Adding the Office Primary Interop Assemblies as a Prerequisite in your ClickOnce installer (Mary Lee)

    • 46 Comments

    When you use ClickOnce in Visual Studio 2008 to deploy your Office solution, you can include prerequisites such as the .NET Framework 3.5, the Visual Studio Tools for Office system 3.0 Runtime, and Windows Installer 3.1.  However, the primary interop assemblies (PIAs) for the 2007 Microsoft Office system are not automatically listed in the Prerequisites dialog box. 

    Fortunately, you can add the PIAs to the Prerequisites dialog box. The following procedure adds the 2007 Microsoft Office Primary Interop Assemblies to the Prerequisites Dialog Box. This procedure may look lengthy, but you only have to do it once.

    1.  Download the OfficeVSTO2005SEWindowsInstallerV3.msi sample, which is part of the deployment whitepaper at Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer (Part 1 of 2).

    2. Install OfficeVSTO2005SEWindowsInstallerV3.msi.

    3. Copy the contents of %ProgramFiles%\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample Version 3\packages to %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages

    4. Compile the component checker. This step checks if the computer has the correct version of Office installed to match the PIAs that are being installed.

    a) Open a Visual Studio command prompt

    b) Change directories to %ProgramFiles%\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample Version 3\projects\Checks

    c) Type the following command: cl.exe /Oxs /MT /GS ComponentCheck.cpp advapi32.lib

    d) Copy ComponentCheck.exe to the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA folder and the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2003PIA folder.

    5. Download and extract the Office 2007 PIAs from 2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies.

    6. Copy the o2007pia.msi file to the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIA folder.

    7. In VS2008, on the Project menu, click ProjectName Properties.

    8. Click the Publish tab.

    9. Click the Prerequisites button to open the Prerequisites dialog box.

    You should see the PIAs listed in the Prerequisites dialog box like the following image. Because the package.xml file does not define a HomeSite (a location to download the file), you will see a build warning.  Even if you have selected Download prerequisites from the component vendor's web site, the PIAs will go into a directory alongside your solution installer.

    Prerequisites

    If you want to learn more about adding your own entries to the Prerequisites dialog box, see Adding Custom Prerequisites.

    For more information about common problems when deploying the Office primary interop assemblies, see http://blogs.msdn.com/vsto/archive/2008/05/20/common-pitfalls-during-pia-deployment-and-installation.aspx.

    For troubleshooting assistance, try the VSTO Power Tools, a suite of tools to help you develop and deploy Office solutions. For example, you can use the VSTO Troubleshooter to examine end user computers for missing prerequisites.

    Mary Lee, programming writer.

Page 1 of 2 (12 items) 12