VSTO project with multiple versions of office installed - visual-studio-2010

I currently have office 2010 installed, and am trying to assist a coworker who's still using 2007 with VSTO solution. This is turning into a mess since my copy of visual studio thrashes the project files updating them to point to the O2010 dlls. If I were to install office 2007 beside 2010 would I be able to open the solution without the upgrade wizard mangling everything, or are my only options making significant architectural changes to the solution or reverting to O2007 until my employer makes O2010 the new standard.

You cannot run Outlook versions side-by-side (and here).
You can still target both 2007 and 2010, but you need to research embedded interop types.

You shouldn't need to install Office 2007 to create Office 2007 add-ins. I think the problem here is that you're missing the proper VSTO components.
Make sure you've installed the following:
All .NET and developer tools from Office (from the Office 2010 installer -- no need for the Office 2007 installer)
Microsoft Office Developer Tools from Visual Studio (from the VS installer)
Microsoft Office 2007 Primary Interop Assemblies
Microsoft Visual Studio 2010 Tools for Office Runtime
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0 Runtime)
If any of these are already installed then I recommend repairing their installations.

Try disabling this option:
Options > Office Tools > Project Upgrade > Always upgrade to installed version of Office (more info here)
I don't think this solves the root problem which is that you shouldn't even be prompted to upgrade your project. I still suspect that there is something wrong with the installation of your VSTO-related components (see my other answer for that info). However this may be an easy workaround.
To be clear, you can develop Office 2007 add-ins without having Office 2007 installed. I'm doing so right now without having to follow this workaround.

Related

Missing Outlook 2013 Add-in

I am working on making a Outlook Add-in for Outlook 2013. The issue is, I use Visual Studio 2010. I did some googling and found that I need the Developer Tool Kit and it lead me here. I installed the tool kit, but I am still not seeing any new Templates. What am I doing wrong, or what can I do to get that Outlook Add-in?
Thanks in advance!
Unfortunately VSTO allows creating version-specific add-ins. VSTO 2010 (Visual Studio 2010 Tools for Office Runtime) is shipped with Visual Studio 2010 Professional edition or above. It supports creation and editing of document- and application-level add-ins for Office 2007 and Office 2010. You need to use later Visual Studio versions for creating COM add-ins for Office 2013. However, you can run solutions in Office 2013 that were created in earlier Visual Studio versions, see Running Solutions in Different Versions of Microsoft Office for more information.

Office 2016 add-in development in Visual studio 2013

We need to develop add-in for the Office 2016. We are using the Visual studio 2013. It is only showing the Office 2013 add-in templates. Is it possible to create Office 2016 add-in from Visual studio 2013? If so, kindly let me know the steps.
You need VS 2015 to get the specific templates for Office 2016. VSTO only ever provides templates for "current" versions of Office.
If Office 2013 is installed you can develop an Add-in for it. There should be no problem installing and running it in Office 2016 - unless you want to use technology specific to 2016. In that case, you could use late-binding (PInvoke) for the 2016-specific portions, but debugging/testing would be a bit of a pain.
You can download the free Visual Studio 2015 Community edition (https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) as well as the VSTO package (https://www.visualstudio.com/en-us/features/office-tools-vs.aspx): VSTO does integrate into the Community edition for version 2015 (and 2013, for that matter). Licensing restrictions would apply, of course.
Other than that, you'd need to upgrade to a full VS 2015.
You can develop and run Office 2016 addins in VS2013. No need to upgrade to VS2015.
Install VSTO 4.0 extension for VS2013
Create Office 2013 plugin using Visual Studio template
Open project file and replace office version string "15.0" to "16.0" in ProjectExtensions section. Look for this of similar string to edit:
OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Outlook" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\15.0\Outlook\InstallRoot\Path#outlook.exe"
Yes, it is possible. The add-in created in Visual Studio 2013 can be run in Office 2016. You can read more about that in the Running Solutions in Different Versions of Microsoft Office article.
In case if you need to use new methods and properties available only in Office 2016 you can use the Reflection mechanism (see Type.InvokeMember).
there is an example for Outlook, i tried it for Excel and it works as well.
my example:
<ProjectProperties HostName="Excel" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="16.0" VstxVersion="4.0" ApplicationType="Excel" Language="vb" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Excel\InstallRoot\Path#excel.exe" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{DCFE8D25-4715-4C33-9EAB-A34A9EBC9544}" />
i changed
OfficeVersion="15.0"
to
OfficeVersion="16.0"
and the path to Excel
#Software\Microsoft\Office\16.0\Excel\
as well, finally it starts in Excel 2016...

Visual studio Word Addin 2010 does not load in office 2007

I have developed word addin 2010 using visual studio 2012. I have created setup file using below MSDN link.
http://msdn.microsoft.com/en-us/library/cc442767.aspx
When i run this for ofice 2010 or office 2013 it works fine but it doesn't work for office 2007.
I though it would be word addin issue so I have created word addin 2007 and still have issue.
Can somebody suggest what can be the issue?
Add-in functionality changed again between Office 2007 and 2010, to support new features like the changed UI (RibbonBar). The addin you created for Office 2010 uses features that did not exist in the Office 2007 apps (Word/Excel etc).
Office Add-ins are typically forward compatible only. That is future version of Office support older older plugins, but the opposite is simply not possible as new features get added all the time.
e.g.
Write an Office 2007 addin and it will likely work on Office 2007, Office 2010 and Office 2013.
Write an Office 2010 addin and it will likely work on Office 2010 and Office 2013.
Write an Office 2013 addin and it will likely only work on Office 2013.
Please note that while they "work" they will often look very old-fashioned as they typically use the older UI elements and not the latest version.
Create a 2007 add-in instead
If you really need Office 2007 support, you need to create a 2007 Add-in instead (as well?). Otherwise you will likely be using features that simply do not exist in Office 2007. The only possible (unlikely) alternative is to add Office 2010 DLLs to the machines, but as you are then effectively upgrading Office I doubt that is legal without a Office 2010 licence (so you might as well upgrade them anyway).
Try to attach to the project the Interop.Word dll of Word 2007.
Also exchange the Office Object Library dll 12- which comes along with Word 2007.
Hope this helps.

Outlook add-in migration to vs 2010

We have an outlook add-in project in visual studio 2008 that uses VSTO 2005. This works with outlook 2003 and outlook 2007 so far.
Now my company is moving to visual studio 2010 so I tried to migrate to visual studio 2010 with VSTO 2005, I am having a few compilation problems. My question:
Will VSTO 2005 work on vs 2010 and the project will compile and run as usual?
If not, is there any workaround to support outlook 2003 for development with VS 2010, if it exists will it work on outlook 2010 also.
If this is not possible, is it advisable to keep two separate projects one for outlook 2003 (in vs2008) and other for outlook 2007-2010 (in vs 2010)?
Thanks for your time
I researched VSTO 2010 upgrade options for a project a couple months ago. This MSDN link lists which versions of Office can be targeted by VSTO 2010. It states: "If you need to create a solution that can also run in Microsoft Office 2003, you must use an earlier version of Visual Studio." To specifically answer your questions.
No
The only workaround that was mentioned anywhere was to use C++ to write your own Office addin loader. I did not find any examples of how to do this, and it did not seem like a reasonable option anyway.
Maintaining two projects is an option if you really need to support office 2003. It just depends on if you are willing take on the extra work of maintaining two code bases.
Another option would be to keep using VS2008 to target Office 2003-2010. However that would prevent you from taking advantage of .NET 4 and any Office 2010 specific features.
We simply decided to no longer support Office 2003 once we moved to VS2010.
A great part of my customers are still running Office XP / Office 2003 installations, and are only planning for an upgrade to Office 2010. I think in big corporate environments Office 2003 will stay until end of 2012.
So if you want to support this share, you'll have to consider this large client base.
I'm working a lot with a third-party tool called Add-in Express. This allows to create add-ins for different office versions independently from the VSTO complications, because they use their own loader. I've targeted Office 2003 with commandbar-based UI and Office 2007/2010 with ribbon UI in the same add-in with the same codebase.
May be it's worth to have a look at this tool.

VSTO Development with Office 2003 and 2007 installed side-by-side?

Does VSTO 3.0 (using Visual Studio 2008) support both Office 2003 and Office 2007 installed side-by-side on a single development computer so that both Office 2003 and Office 2007 can be targeted (in separate solutions)?
I have seen conflicting information about this.
NO: http://msdn.microsoft.com/en-us/library/bb398242.aspx
Visual Studio Tools for Office does not support installing Microsoft Office 2003 and the 2007 Microsoft Office system (or different versions of the same application, such as Word 2003 and Word 2007) side-by-side on the development computer. To develop solutions for different versions of Microsoft Office, use a different development computer for each version of Microsoft Office.
YES: http://msdn.microsoft.com/en-us/library/15s06t57.aspx
When you install Visual Studio Tools for Office, the primary interop assemblies are automatically installed to a location in the file system, outside of the global assembly cache. When you create a new project, Visual Studio Tools for Office automatically adds references to these copies of the primary interop assemblies to your project. Visual Studio Tools for Office uses these copies of the primary interop assemblies, instead of the assemblies in the global assembly cache, to resolve type references when you develop and build your project.
These copies of the primary interop assemblies help Visual Studio Tools for Office avoid several development issues that can occur when both the 2003 and the 2007 versions of the Office primary interop assemblies are registered in the global assembly cache.”
Has anyone done this and were there any problems?
You can target both 2003 and 2007 with the same computer - but you need two different programs for that in Visual Studio (e.g. MyCoolThingfor2003.sln and MyCoolThingfor2007.sln) as they have different interops. But you should not have both Office programs installed on that same computer.
You can't install Office 2003 and 2007 side by side. The two links you posted talk about different things. The first link says no to installing the actual Office 200x application, whereas the second link refers to the PIA (which is just a wrapper). You can install any version of the PIAs on a computer side by side, but it doesn't mean it'll launch different versions of office.
If your goal is to develop a VSTO addin that supports both Office 2003 and Office 2007, then you'll need to develop on a system with VS2008 + Office 2003.

Resources