VSTO 2012: backward compatibility

2019-05-10 07:24发布

Since lately the Visual Studio Tools For Office 2012 (VSTO 2012) are available for download.

Can this new version still used for developing Add-In solutions for older Office versions (2007,2010)? Are there any advantages over VSTO 4.0 (besides Office 2013 support)

2条回答
Explosion°爆炸
2楼-- · 2019-05-10 07:43

Yes, it can. I'm using VS2012 for an Excel 2007 project and it works fine.

The trick is to change the debug path in your project file so that VS uses the older version of the Office app your plugin is for.

  1. Create your VSTO project (let VS create the project for Office 2010)
  2. Edit the project file and find the <ProjectProperties> with a HostName attribute. It will be a child element of a <VisualStudio> element.
  3. Change the DebuginfoExeName attribute value of the <ProjectProperties> attribute to be the path to the older version of the Office application .exe file
  4. Save your project

Now when you go to debug your app it should launch the older version of your Office app and attach to that process to load your VSTO.

In my project, the new <ProjectProperties> element looks like this for Excel 2007:

<ProjectProperties
    HostName="Excel"
    HostPackage="{20A848B8-E01F-4801-962E-25DB0FF57389}" OfficeVersion="14.0"
    VstxVersion="4.0"
    ApplicationType="Excel"
    Language="cs"
    TemplatesPath=""
    DebugInfoExeName="#Software\Microsoft\Office\12.0\Excel\InstallRoot\Path#excel.exe"
    AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />

Deployment also works fine. I deploy my add-in via ClickOnce and it is added to Excel 2007 clients without any additional changes.

查看更多
相关推荐>>
3楼-- · 2019-05-10 07:49

As far i know you can deploy your solution to previous version office. I once developed an add-in for ppt 2013 and it worked fine in ppt 2010. Note that The API for the new VSTO has several additional features and last time i only used existing features, but not the new ones.

I've never tested this, but i think if you use new event handler that only works in 2013, when you deploy it in 2010 it simply does nothing / doesn't work.

As i mentioned, the obvious advantage of new VSTO is more features available, for example in ppt 2013, it has event handler when the users do dragging, you should checked them by yourselves. If your solution doesn't need these new features, you can develop it in the previous version of VSTO to make sure the backward compatibility.

查看更多
登录 后发表回答