简体   繁体   English

运行时错误1004:无法运行宏'Solver [InsertFuction]'

[英]Run-time error 1004: cannot run the macro 'Solver[InsertFuction]'

Basically, this issues arises from this topic: SolverOptions: How to find the parameter position (AssumeNonNeg)? 基本上,此问题由以下主题引起: SolverOptions:如何查找参数位置(AssumeNonNeg)?

When I open a file and import the .bas file and run it, everything works fine. 当我打开文件并导入.bas文件并运行它时,一切正常。 However, when I try to apply the same procedure for all similar files using shell via VB script, I am getting the following error: 但是,当我尝试通过VB脚本使用Shell对所有相似文件应用相同过程时,出现以下错误:

Run-time error 1004: cannot run the macro 'SolverReset'. 运行时错误1004:无法运行宏'SolverReset'。 The macro may not be available in this workbook 该宏可能在此工作簿中不可用

I initially tried without SolverReset and in that case I got an error saying 我最初尝试不使用SolverReset ,在这种情况下,我收到一条错误消息:

Run-time error 1004: cannot run the macro 'Solver' The macro may not be available in this workbook. 运行时错误1004:无法运行宏'Solver'该宏可能在此工作簿中不可用。

It looks like as if Excel is not activating Solver add-in? 看起来好像Excel没有激活规划求解加载项? What might be the problem here? 这可能是什么问题?

Thank you! 谢谢!

After many trials the following worked for me: 经过多次试验,以下对我有用:

in front of each Solver function (eg. SolverReset , SolverOptions , etc.) I put Solver.xlam! 在每个Solver函数的前面(例如SolverResetSolverOptions等),我将Solver.xlam!放进去Solver.xlam! and ran the code. 并运行代码。 It didn't work but gave a warning that there was no Solver.XLAM in the directory. 它没有用,但是警告目录中没有Solver.XLAM So I simply went to the folder C:\\Program Files\\Microsoft Office\\Office15\\Library\\SOLVER and copied both Solver.XLAM and Solver32.DLL to the directory. 因此,我只是转到文件夹C:\\Program Files\\Microsoft Office\\Office15\\Library\\SOLVER然后将Solver.XLAMSolver32.DLL复制到该目录中。 That was it! 就是这样!

Hope someone finds this useful! 希望有人觉得这有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM