I just created a VSTO Add-In for Office 2010. How how do I know which pre-requisites I need and whether or not my add-in would work for both 2010 and 2007 or just 2010? I'm confused why this seems obvious based on the lack of documentation on this topic. During compilation it tells you if there is a problem if you're building for instance on .NET Client profile instead of the full .NET but for all the other prerequisites I don't know how to tell. Do I need for instance the Visual Studio for Office 2010 Runtime and the Interlop Assemblies?
This might be of interest:
https://stackoverflow.com/a/4411365/1373170
and https://stackoverflow.com/a/1596868/1373170
If you are on .NET 4, you don't need to ship PIA anymore, if you use embedded interop assemblies.
The VSTO Runtime would still be required I believe.
Related
I'm coding one of my first projects in Visual Studio 2017 using the Microsoft Office Interop Tools to basically open some Word files, extract some content and export it to an XML file.
I know that on the target machine Office should be installed and actually on that PC a 2010 installation is licensed, while on my PC I have a 365 suite.
The first build was working only on my PC, with missing references errors to the interop library on the production PC, so I've downloaded the Microsoft Office 2010: Primary Interop Assemblies Redistributable
https://www.microsoft.com/en-us/download/details.aspx?id=3508 to include as a reference in my project, replacing the 2016 one.
First difficulty was: Once installed I cannot find the files on my drive, nor a reference inside visual studio, nor in the documentation. Is there any info about where to pick the dll?
So I unzipped from the cab the WORDPIA.DLL on an handy directory and referenced it in my project.
While is it working locally, it isn't yet on the production PC.
I'm sure I'm missing a lot of points on this topic, VS & C# are not my territory, but I need some tips to finish the project.
Go back to the original project (or reference the version of the PIAs installed on your machine). The redistributable is intended for installing to an Office 2010 machine where the PIAs were not installed. It's not meant to be used in the manner you envision.
Now click each "interop" reference entry and look at the Properties window. There should be a setting for "Embed Interop Types". Set that to True. This should make the project version-independent as it will contain the PIA information your project uses.
Note that "embed interop types" was introduced with .NET Framework 4.0 and is not available for earlier versions of the Framework. If an earlier version is a requirement, then you have to use late-binding or develop your project using Office 2010.
I have a Excel addin written in VBA which iterates through used range of a sheet and manipulates cell values. Its a simple addin but now user requirements have changed and I want to develop it in C# in Visual studio. For this purpose i was looking into VSTO but as far as i can understand in visual studio you can develop addin for a single version of excel. I have to give support for excel 2010 and excel 2013. What should I do to overcome this issue. which visual studio version i should use?
Any version of Visual Studio from 2010 to the present should be able to create VSTO Add-ins for Excel 2010. From VS 2012 onwards, also for Office 2013. Which set of templates you see in the later versions depends on 1) the version of Office installed and 2) the version of the .NET Framework selected when creating the project (4.0 for 2010; 4.5 for later). More information can be found on this page: https://blogs.msdn.microsoft.com/vsto/2013/03/06/office-developer-tools-for-visual-studio-2012-now-available-with-office-2013-and-net-framework-4-5-support/
Note that you should have only one version of Office installed in the development environment.
If possible, you should develop the Add-in for Excel 2010. An Add-in developed for an older version will run for a newer version, without you needing to do anything in addition - assuming Microsoft hasn't made changes to the parts of the object model you use which will "break" it. Since Microsoft pays special attention to backwards compatibility, this is usually not a problem, but thorough testing is important. It is not necessary to re-build or otherwise change the installation for installing to a newer version of Office.
One important reason to develop against the older version is that forwards compatibility is not supported. In other words, if you should use something in the newer version that's not present in the older one, that code will fail.
Also, the VSTO functionality will automatically "re-map" references made to an older set of PIAs to the newer ones for a newer version of Office. The reverse is not the case.
If for some reason it's not possible to program using the older version, as long as you have the .NET Framework 4.0 (or later) you can use the "Embed Interop types" property of a Reference to embed the PIA information in your project, so that it travels with your solution instead of referencing the PIAs installed in the GAC and makes them version independent. This is fine, in theory, but requires very thorough and careful testing since - besides the forwards compatibility problem - the actual information embedded does not always behave correctly.
you need to install visual studio 2013 for VSTO version 13 that support Excel 2013, but you can support excel 2010 by creating the installer file from the application. and there is no other way to support two different version from the code base at the same time
Thanks
I have an addin that is compatible with Outlook 2003 - 2013 by using the various versions of VSTO.
It seems that the majority of small businesses will have the Click To Release version, which is not compatible with addins.
Is there a way to make an addin compatible with 2013 C2R, or does it need to be rewritten to be an "App" using Napa?
C2R Office installation load COM addins in exactly the same way as the regular version of the Office, there is nothing you need to do.
What is the exact problem that you are running into?
I'm trying to develop an MS Office Addin in C# .Net and I don't have access to Visual Studio. Instead I'm using SharpDevelop as my IDE, (but my question is equally relevant to anyone developing using any other IDE or compiling from the command line...)
I've done a bit of searching for guides on how to develop AddIns, but they all seem to require Visual Studio and follow these steps:
Install the Interop Assemblies
Create a Visual Studio .Net Project (I'm unable to do this bit)
Extend the VS ThisAddIn template
What I've managed to do is to:
Install the Interop Assemblies
Create a C# empty SharpDevelop project
Add a GAC reference to Microsoft.Office.Interop.Outlook
Add a COM reference to Microsoft Office 12.0 Object Library
add the line using Outlook = Microsoft.Office.Interop.Outlook;
and the line using Office = Microsoft.Office.Core;
Look at some example code and realise that they all refer to VS templates and VSTO libraries (Microsoft.Office.Tools) which I don't have.
Where do I go from here? Is there a guide/tutorial I've missed, or can someone provide some pointers?
NetOffice (http://netoffice.codeplex.com or https://osdn.net/projects/netoffice/) is a great set of version-independent interop assemblies for Office. This is all you need to make add-ins using SharpDevelop, and the project has a bunch of tutorials and samples too, including some for Outlook.
If you're making an add-in for Excel using Excel-DNA (which you need to expose user-defined worksheet functions from .NET), NetOffice still gives you a complementary set of libraries for accessing the Excel COM automation interfaces from your Excel-DNA add-in, so they work together well.
For both NetOffice and Excel-DNA, you'll also be able to use the free Visual Studio Express editions (with some small tricks needed to get debugging working). Visual Studio Express does not include VSTO at all. SharpDevelop also has many more features than the Express editions, like built-in refactoring and VB.NET <-> C# translation tools, so there are good reasons to prefer SharpDevelop as your free IDE.
EDIT: I missed the reference to Outlook, my apolgies.
For Outlook, look here. Outlook Redemption is useful.
I'm not a Word Expert, but there are plenty of tutorials on the web.
For Excel I'd suggest you actually look at ExcelDNA
Plenty of SO questions on this topic. See Exposing .net methods as Excel functions? for example as additional advice on where to start and what your options are.
We need to create a VSTO add-in in C# that supports both Outlook 2007 and 2010.
To start off we created 3 projects:
File->New Project->Office->2007->Outlook 2007 Add-in
File->New Project->Office->2010->Outlook 2010 Add-in
File->New Project->Windows->Class library
All shared code is in project #3.
So far, we have partially developed the add-in and have been using ClickOnce deployments for testing.
One day, we noticed someone installed the 2010 add-in for 2007 Outlook and had no ill effects whatsoever.
So a few questions:
Is there any reason to create the
2007 VSTO project? Can we just
create the 2010 project?
Or is the only difference the version of
the office runtime that is
bootstrapped by the ClickOnce
installer? Can you just install the 2010 runtime for Outlook 2007?
If there is no difference, why are
there two Visual Studio project
templates?
In our final solution, we will be using a WiX installer, which is also working thus far. The WiX installer will be simplified greatly if we can use 1 project for the add-in.
Is there any reason to create the 2007 VSTO project? Can we just create the 2010 project?
You can just use the 2010 project, but if you accidentally reference any 2010 ONLY api's, for example accessing any of the new conversation API's will cause your add-in to blow up in 2007.
Or is the only difference the version of the office runtime that is bootstrapped by the ClickOnce installer? Can you just install the 2010 runtime for Outlook 2007?
Basically you are writing a VSTO 3.0 add-in, which works for both 2007 and 2010. VSTO doesn't actually care which template you are writing for, only that your add-in is a VSTO 3.0 add-in.
If there is no difference, why are there two Visual Studio project templates?
2 reasons that I can see, F5 debugging support, and to make sure you do not access a new API'
If you do go down the only 2010 add-in road, I suggest you do a compile of the solution against the Microsoft.Office.Interop.Outlook v12 PIA which will show you any new API's that you are accessing. If you do want to target some of these new API's only IF your add-in is hosted in 2010 then have a look at http://blogs.msdn.com/b/vsto/archive/2010/06/04/creating-an-add-in-for-office-2007-and-office-2010-that-quot-lights-up-quot-on-office-2010-mclean-schofield.aspx