Excel 中用于 Windows 7 的开发工具控制台

Console of Dev Tools in Excel for Windows 7

我已经构建了一个插件,它在 Excel 线上运行良好,但在 Excel 2016 中不适用于 Windows。

我知道在 Windows 10 中,我们可以使用 this tool 来调试加载项,但是我使用的是 Windows 7.

我刚刚安装了 Visual Studio 2017,右键单击加载项会显示 Attach Debugger 所在的菜单。但是点击 Attach Debugger 什么也不会触发。

有人知道在这种情况下如何调试吗?

两个可能的选择:

您可以使用 Volorn.js to remotely debug your add-in. You can use the Debug Office Add-ins on iPad and Mac 文章作为起点。尽管本文针对 Mac 和 iPad,但概念与 Windows 相同。

您还可以通过创建新的 Excel Web 插件来使用 Visual Studio。只需将默认清单替换为您自己的清单即可。请注意,您仍然需要保留默认网站,Visual Studio 仍然需要保留默认网站以供某些图书馆参考。但是,它将使用清单的 URL 作为源位置。

Office 应用程序使用 Internet Explorer 作为 Web 浏览器,因此 IE 中的所有设置都应沿用。我发现如果您禁用(取消选中)Disable script debugging (Internet Explorer)Disable script debugging (Other) 选项,您的调试器断点将被击中(我在 Outlook 2016 中对此进行了测试)。

您需要添加 debugger; statements to the source code to add breakpoints. When these statements are hit, a dialog like this should appear:

只需 select 'Yes' 和 visual studio 的新实例应该打开,调试器附加到您的脚本。