XLS Padlock Guide
XLS Padlock Guide

Passing more parameters to the compiled VBA code

 

 

VBA Code Protection > Passing more parameters to the compiled VBA code

By default, the helper function seen in "Writing and compiling secure VBA code" and used to run the compiled VBA code supports one parameter only.

' This function lets you call VBA macros compiled with XLS Padlock
Public Function CallXLSPadlockVBA(ID As String, Param1)
Dim XLSPadlock As Object
On Error Resume NextSet XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
CallXLSPadlockVBA = XLSPadlock.PLEvalVBA(ID, Param1)
End Function

 

The highlighted line shows that the PLEvalVBA method of the XLSPadlock object takes two parameters: ID and Param1.

This XPSPadlock object has other methods if you want to pass more parameters to the compiled VBA code:

XLSPadlock.PLEvalVBA2(ID, Param1, Param2) for two parameters.

XLSPadlock.PLEvalVBA3(ID, Param1, Param2, Param3) for three parameters.

It is even possible to pass more parameters by using arrays.

For instance, the helper function to pass two parameters to the compiled VBA code would be:

' This function lets you call VBA macros compiled with XLS Padlock
Public Function CallXLSPadlockVBA(ID As String, Param1, Param2)
Dim XLSPadlock As Object
On Error Resume NextSet XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
CallXLSPadlockVBA = XLSPadlock.PLEvalVBA2(ID, Param1, Param2)
End Function

 

Passing arrays to the compiled VBA code