vba 程序太大
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3751263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Procedure Too Large
提问by Sourav
I received this error message -Procedure too large- in VBA. What is the reason and way out for this error?
我Procedure too large在 VBA 中收到此错误消息。这个错误的原因和出路是什么?
回答by Hans Olsson
You probably have one or more gigantic procedures/functions and I think VBA has a limit of 64k or something per procedure.
你可能有一个或多个巨大的过程/函数,我认为 VBA 有 64k 或每个过程的限制。
You fix it by splitting that procedure up into multiple procedures that can then be called by the one procedure.
您可以通过将该过程拆分为多个过程来修复它,然后这些过程可以被一个过程调用。
So instead of having:
所以,而不是:
Sub GiantProcedure()
... ' lots and lots of code
End Sub
You'd have something like:
你会有类似的东西:
Sub GiantProcedure()
... ' a little bit of common code
Proc1()
Proc2()
Proc3()
End Sub
Sub Proc1()
... ' quite a bit of code
End Sub
Sub Proc2()
... ' quite a bit of code
End Sub
Sub Proc3()
... ' quite a bit of code
End Sub
回答by Wix
Your compiledprocedure cannot exceed 64kb. You should break it up into different sub routines.
您编译的程序不能超过 64kb。你应该把它分解成不同的子程序。
回答by Dirk Vollmar
You might get this error message if the macro has been created using the 64-bit version of Office. See the following article for further details and a workaround:
如果宏是使用 64 位版本的 Office 创建的,您可能会收到此错误消息。有关更多详细信息和解决方法,请参阅以下文章:
回答by Siamak
The idea of GiantProcedure didn't work for me, using Microsoft Powerpoint 2013. Then I added a "call" before each "proc". Like this:
GiantProcedure 的想法对我不起作用,使用 Microsoft Powerpoint 2013。然后我在每个“proc”之前添加了一个“调用”。像这样:
Sub GiantProcedure()
Call Proc1()
Call Proc2()
Call Proc3()
End Sub
Now, it works.
现在,它起作用了。

