Compile VBA code from command line
VbaCompiler for Excel allows for the compilation of VBA code from the command line.
This is a convenient way to compile VBA code, be it VBA code that contains large amounts of Excel files in batch mode or just for registration key generation from the command line.
This feature is available in the registered version of VbaCompiler for Excel.
The computer where you want to call VbaCompiler for Excel from command line should have Windows 7 or higher installed, as well as Excel 2007 SP3 or higher. The Microsoft Excel should have the latest service pack and updates installed.
Syntax for VBA compiling from the command line
vbaclr4e.exe <name of the excel file with VBA code> [-switch[=value] …]
-bit – bitness of compiled DLL file—32 or 64 bit. Available values for this switch are x86 for 32 bit and x64 for 64 bit. The default value is ‘x86’.
-tgt – the full name of the target workbook. This parameter defines the location as well as the file name of the target xls file with the compiled VBA code.
-tdll – The name of the target dll. If this switch is missed then the default value that will be used is equal to the name of the workbook plus the defined bitness of the compilation as an additional substring. For example, in the case of the workbook with the file name of “Sample.xls” — the default dll name will be “Sample_xls_32.dll”.
-ol – the c-compiler optimization level. Valid values of the -ol switch are: O0, O1, O2, Ofast, Os. you may find the meaning of each value in the VbaCompiler for Excel compilation options description. If the switch is missed, then the default value ‘O1’ is used.
-acontact – the author contact as an email address or http web address.
-appname – the application name. The internal name of the application which is used for coupling the compiled VBA code and registration key file.
Example: -appname=”My Workbook Application”
-rkname – the name of the registration key file. This switch enables the “Copy protection with registration key” mode.
-hwlock – the hardware locking flag. This switch is used when you need to enable the hardware locking option. This switch doesn’t have any value to be assigned and must be used in combination with the -rkname to take effect.
-trial – flag that determines a trial/demo version. This switch enables the Trial/Demo mode for a compiled workbook. This switch doesn’t have any value to be assigned and must be used with -rkname switch to be effective.
-trial_nag_delay – the trial nag window delay before the ‘Close’ button becomes shown, determined in seconds. This switch’s value is the time of delay in seconds and must be used with the -trial switch to have any effect.
-unviewable – the flag that makes VBA code unviewable. This switch enables the unviewable VBA project mode for a workbook with compiled VBA code and doesn’t have any value to be assigned. Example: -unviewable
-custom_rsc – the full name of the custom resource dictionary file. This switch attaches custom resource dictionary files to the compiled workbook.
Create registration/activation key from command line
Syntax for command line registration key generation
vbaclr4e.exe <the full name of the compiled VBA dll file> -rkgen=<the full name of the ini-file with regkey parameters>
-rkgen – the registration key generation for VBA code compiled with the ‘Copy protection with registration key’ mode enabled. The value assigned to this switch must be the full name of the file in ini-file format containing the parameters of the registration key.
Example of the registration key parameters inside of the ini-file
name=Customer Name email=CustomerName@email.com date_from=01/22/2019 date_to=02/22/2020 compid=M5YN-J7XB-MB9M-EIMM-ZYI9D-HQTAA
The left side of each ‘=’ symbols is the key value which must be kept the same as in the example:
name – The customer name.
email – The customer email.
date_from – The date of the beginning of the registration key validity term.
date_to – The date of the end of the registration key validity term
compid – The customer’s computer id.
Example of a registration key command:
vbaclr4e.exe “d:\VbaCompiledFiles\ApproxPi_xls_32.dll” -rkgen= “d:\regkey.ini”
You may find the status of the VBA code command line compilation in the build log file, which is located inside your target folder.
The name of build log file is <name of workbook>.BuildLog.txt.