Office 2016 add-in development in Visual studio 20

2019-04-12 10:39发布

问题:

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.

回答1:

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.



回答2:

You can develop and run Office 2016 addins in VS2013. No need to upgrade to VS2015.

  1. Install VSTO 4.0 extension for VS2013
  2. Create Office 2013 plugin using Visual Studio template
  3. 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"



回答3:

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).



回答4:

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...