如何使用VBA

时间:2016-04-07 15:46:56

标签: excel vba excel-vba

我遇到了一个有很多变量的问题,正常的Excel解算器需要花费大量时间来解决问题。我正在使用excel opensolver,因为它更快,更高效。我试图录制一个宏,但看不到任何与opensolver相关的代码。我需要使用VBA访问开放求解器,就像我们对普通excel求解器一样。

提前致谢!

2 个答案:

答案 0 :(得分:2)

这就是我为刚刚创建的玩具优化问题而努力的方法:

  • 将Opensolver引用添加到VB项目

References menu...

OpenSolver reference

  • 按照以下示例代码调用解算器:

    Sub Test_OpenSolver()
        OpenSolver.RunOpenSolver , False
        'Q: Why False as a Second parameter?
        'A: MinimiseUserInteraction If True, all dialogs and messages will be suppressed. Use this when automating a lot of solves so that there are no interruptions. Defaults to False
    End Sub
    

答案 1 :(得分:1)

OpenSolver没有任何记录宏的能力;它不是我们的用户曾经要求的功能。但它确实有一个记录良好的VBA接口;请参阅使用OpenSolver下的AppInit_DLLs in Windows 7 and Windows Server 2008 R2