Procedure Too Large

青春壹個敷衍的年華 提交于 2020-01-09 03:50:06

问题


I received this error message -Procedure too large - in VBA. What is the reason and way out for this error?


回答1:


You probably have one or more gigantic procedures/functions and I think VBA has a limit of 64k or something per procedure.

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



回答2:


Your compiled procedure cannot exceed 64kb. You should break it up into different sub routines.

http://msdn.microsoft.com/en-us/library/Aa264541




回答3:


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:

"Compile Error: Procedure too large" error message when you try to run a VBA macro in a 32-bit version of an Office 2010 program




回答4:


The idea of GiantProcedure didn't work for me, using Microsoft Powerpoint 2013. Then I added a "call" before each "proc". Like this:

Sub GiantProcedure()

  Call Proc1()
  Call Proc2()
  Call Proc3()

End Sub

Now, it works.



来源:https://stackoverflow.com/questions/3751263/procedure-too-large

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!