Get the value of a variable

Sure, you can do this:
  1. in XLS Padlock VBA Compiler, type this:

    Function RetrieveMyVariable
    RetrieveMyVariable = 50 'Anything you want to return
    End Function
For instance, we want to retrieve 50.
Click Compile Code and close the compiler’s window:


image.png817×505 30 KB

  1. Open VBE and in the workbook’s code (for instance a module), type this:

    Sub RetrieveFromVBACompiler()
    Dim XLSPadlock As Object
    Set XLSPadlock = Application.COMAddIns(“GXLSForm.GXLSFormula”).Object
    MsgBox XLSPadlock.PLEvalVBA(“RetrieveMyVariable”, “”)
    Set XLSPadlock = Nothing
    End Sub

image.png793×296 16.8 KB


That’s all. Even if you execute the VBA procedure RetrieveFromVBACompiler from VBE, it will work:


image.png180×171 1.66 KB


We were able to import a variable from the VBA compiler and retrieve it from usual VBA code in VBE.
 

Attachments

  • image.png
    image.png
    30 KB · Views: 1
  • image.png
    image.png
    16.8 KB · Views: 1
  • image.png
    image.png
    1.7 KB · Views: 1
Back
Top