VBA Compiler and protection

A few general queries on this topic:

  1. Is it possible to pass a complete sub routine to the compiler?
  2. Is there a limit on the size of code that can be compiled?
  3. If a sub routine uses functions should those functions be put through the compiler first?
    Thanks
    Dave
  1. Can you please clarify? Is it an existing subroutine inside the compiler to another one?

  2. There isn’t an explicit limit on the size of code. It will depend on the available memory.

  3. Yes, you should define them first inside your VBA compiled code.

Hello
Thank you for your reply.
With regard to my item 1) the sub routine might be one of many within the module but may be quite complex. For example the routine may have several If/EndIf statements.

Specifically I am seeking to find out whether each If/EndIf statement should be passed separately to the compiler for compiling or whether the whole sub routine (i.e. all code) can be compiled in one go.

Additionally where UserForms are being used I presume the form is not compiled but you can compile the code behind it.

Hope that makes sense.
Thank you,
Dave

It’s up to you and what are the conditions for the If/endIf statements. Of course, If Then are supported by the VBA compiler.
No UserForm are not compiled, but you are right, you can compile portions of the VBA code behind them for instance.
The real goal of the VBA compiler is to move some vital parts of your VBA code to it, so that your Excel workbook will fail without the compiled VBA code if it somehow is extracted from the protection shell.

Okay I understand. As you mention “If Then” statements being supported is it fair to read into this that not all statements would be supported? In particular I am thinking of Arrays - which are probably the most sensitive for me.

Thank you,
Dave

Arrays are handled too, but sometimes, slow (because of OLE).
See this page:
https://www.xlspadlock.com/doc/topics/vba-code-arrays.htm

That’s both helpful and useful. Experimenting and testing the effectiveness is called for.

Thank you.

1 Like