Excel-DNA,发布Ribbon的onAction代码时出现问题。 F#

问题描述 投票:0回答:1

我正在使用Excel 2010,并尝试在F#中运行Excel-DNA/Samples code以进行功能区自定义。

<tab id='CustomTab' label='My F# Tab'>
   <group id='SampleGroup' label='My Sample Group'>
        <button id='Button1' label='Run a macro' onAction='RunTagMacro' tag='showMessage' />    <!-- works fine -->
        <button id='Button3' label='Dump the Excel Version to cell A1' onAction='OnDumpData'/>  <!-- DOES NOT WORK -->

[Button1的动作有效,并且在第14行上设置一个断点按预期工作。

但是Button3的动作OnDumpData却没有。我可以看到从未调用过该代码,因为从未命中第45行上的断点。

member this.OnDumpData (control:IRibbonControl) =
    let app = ExcelDnaUtil.Application :?> Application  // line 45. Breakpoint here is never reached.
    let cellA1 = app.Range("A1")

[我首先认为这可能是版本控制问题,我试图用.../office/2006/01...替换cutomUI行(#26).../office/2009/07...,但问题仍然存在。

我想念什么(设置或其他东西...)?如何获得Button3正确触发OnDumpData代码?

EDIT1:按照示例文件中的建议,我打开了[[Excel选项“显示外接程序用户界面错误”选项(在“常规”下的“高级”选项卡下]。我在按下Button3时收到的错误消息是:

An exception occurred while calling function "OnDumpDate". Exception message is : Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
...然后我注意到当我关闭调试Excel工作表时,我在VS的输出窗口ExcelDna.Integration Warning: 1 : Assembly OFFICE could not be loaded from resources.中收到此消息。这可能是相关的,但我不确定在哪里解决此问题。
f# ribbon excel-dna
1个回答
0
投票
听起来您需要在项目中添加对Office.dll程序集的引用。这只是与COM相关的PIA程序集(如Microsoft.Office.Interop.Excel)。
© www.soinside.com 2019 - 2024. All rights reserved.