Questions about the VBA compiler


I want to start using the VBA compiler for my projects.

I have a few projects that I didn’t distribute yet and they are 100% pure VBA code.

I’m toking about something like 10K line of code, lots of modules , lots of public/private sub’s and function’s, lots of type’s, Enum’s, Const’s, very strong and tight code.

A few minutes ago I finished a few hours of test’s and learning your VBA compiler and I have a few questions that I didn’t figure:

  • Is the compiler supports WITH statements? it seems that is not and I recommend to add a support if possible, so it will more easy to set (for example) "With Application." In the compiler editor.
  • How can I call another function/sub in the VBA editor inside a function that I want to compile? when I set the key word "Call" in the VBA editor, I get a red line ?
  • I see that I declare a variable in a function that I want to compile BUT Is there a meaning to this declaration ? or all becomes variant ?
  • I have functions with 4,5,6,7 "parameters", can you create more than "PLEvalVBA2" and "PLEvalVBA3" ? I know and understand that can use an array to pass dose parameters but it will add more updating syntax to switch to the VBA compiler
  • Is "goto" supported ?

Thank you !

No, with isn’t supported. And it’s too complicate to handle it.

Try without call: only the name of the sub.

Internally, all variables are treated as variants.

It’s not planned, especially since we added support for arrays (as you noted). But we’ll place your request on our TODO list if others are interested.


The goal of our VBA compiler is not to simulate the entire Excel’s VBA interpreter, but to compile parts of your existing codebase into bytecode (so that, if someone manages to strip the original workbook from its EXE shell, the workbook is affected because of the missing original VBA code).

I totally understand and agree with you, but this is a paradox for me, because the most important functions I have is the most complex ones that contanse Types, Enums, Const’s, refering to other functions ,arrays and so on…

As you probably know, one of the most difficult thing in software is to manage code efficiency for easy changes or fixing bugs and my feeling is that the VBA compiler will add more complexity to my projects to manage, and this is a question for you:
Lets say that I select 3-4 most important functions that I have in a project, how do I manage it with the VBA copliler ? I mean for easy changing to distrabte new versions, and for debuging… do you have any advice for me ?

and few more questions on the VBA compiler:

  1. how can I compile a function that returns an excel object like workbook or worksheet. for this example:

    Public Function GetSheet() As Worksheet
    Set GetSheet = ThisWorkbook.ActiveSheet
    End Function

  2. is the complier support public variables ?

  3. is the complier support public Enums (my declared Enums) ?

  4. is the complier support public Type’s ?

I’m sorry but it’s still show me a red line even without the keyword “Call”

Thank you for your amazing software !!!

If you place the sub to be called before the call, it should then work.

All supported features are listed in the user guide. If you don’t see them listed, then they are not handled.

Actually, the best is to move some minor parts of large and complex functions into the compiler (by creating an intermerdiate sub). The goal is really to make “holes” in your existing codebase, do not move entire VBA functions. Move code that you are sure it doesn’t need to be updated regularly.

Ok I understand that I wasnt clear enough, what I meant is that I want to call a sub/function that is NOT in the VBA complier from a sub/function that is in the VBA complier, is it possible ?

is it possible ?


1 Like

Thank you !

Two more things:

  1. In the user guide not written that “ElseIf” supported but it does, so can add it for others.

  2. is it possible to pass an object like Range from none compiled function to compiled function ?

Thank you.

1 Like

We’ll check. Thanks!

Yes, should be possible.

Ok, how ? i tried every sintex variation…

Please post the code you are trying.

On the VBE

Sub Test()
Dim S As Worksheet
Dim Rng As Range

Set S = Sheets(1)
Set Rng = S.Range("a1:b2")

Call CallXLSPadlockVBA("SelectRng", Rng)

End Sub

Public Function CallXLSPadlockVBA(ID As String, param1)
Dim XLSPadlock As Object
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
CallXLSPadlockVBA = XLSPadlock.PLEvalVBA(ID, param1)
Set XLSPadlock = Nothing
End Function

On the VBA compiler

Sub SelectRng (Rng As Range)  
end sub


Sub SelectRng (Rng)  
end sub

I tried it and it’s not working.

here is a screenshot:

here is the error message i’m geting:


We’ll check. Thanks!