将外部函数的结果分配给变量

时间:2015-09-07 03:13:37

标签: excel-vba vba excel

我有一个主工作簿(wbMaster)和一个奴隶工作簿(wbSlave)。主工作簿具有将用户输入的结果返回到主工作簿中的表单的功能。该功能可以根据需要运行。

我希望能够从slave工作簿中将调用该函数的结果分配给变量。

Public Sub Workbook_Open()

    'The following line (in the wbSlave workbook) runs the function
    'in the master workbook as required, however I don't know how to
    'assign the result of the function to a local variable within the
    'slave workbook.

    Application.Run "wbMaster.xlsm!FormResult.Result"

    'This is what I'm trying to achieve:
    LocalResult = Application.Run "wbMaster.xlsm!FormatResult.Result"

    'but this throws a Compile Error (Expected: end of statement).

End Sub

是否有一种更简单的方法可以让我失踪?

通常,我只是在调用slave工作簿时将函数结果作为参数传递,但这样做会在将参数传递给Workbook_Open函数时导致安全问题。

1 个答案:

答案 0 :(得分:1)

<div class="icon">
  <%= link_to inline_svg(listing.favorite_icon, class: "svg"), favorite_listing_path(id: listing.id), method: :post, remote: true  %>
</div>

如果您要返回一个值,则需要括号。

相关问题