2010-09-20 75 views
13

我收到此错误消息 - Procedure too large - 在VBA中。这个错误的原因和出路是什么?程序太大

回答

16

你可能有一个或多个巨大的程序/函数,我认为VBA每个程序的限制为64k或某些东西。

您可以通过将该程序拆分为多个程序来解决该问题,然后可以通过该程序调用该程序。

其所以不是:

Sub GiantProcedure() 
     ... ' lots and lots of code 
End Sub 

你会碰到这样的:

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 
+7

这个错误是直接从20世纪80年代的... VBA已经达到了古代一个新的水平......面对手掌 – 2014-07-29 15:10:29