Getting command-line parameters passed to the EXE file


Purpose: getting command-line parameters passed to the EXE file

When you run the EXE file, you can pass command-line parameters to it. For some reason, your VBA code may need to retrieve values of these parameters.

Insert the following code:

Public Function ReadParamStr1()

Dim XLSPadlock As Object

On Error GoTo Err

Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object

ReadParamStr1 = XLSPadlock.PLEvalVar("ParamStr1")

Exit Function


ReadParamStr1 = ""

End Function


You can then call the function:

Sub Test_Param()

   MsgBox ReadParamStr1()

End Sub


This code shows a ParamStr1 variable. This variable tells XLS Padlock to return the value of the first command-line parameter. For the 2nd, use ParamStr2 and so on. Up to 3 parameters are handled: others are ignored.


Copyright © 2021 G.D.G. Software