VBA Compiler Options
Excel file with VBA
Single file result ( Embedded DLL )
Disallow to run on virtual machines
Target Excel bitness
Output folder
Work folder
C compiler
C compiler optimization options
Author contact
Compiled DLL file information
DLL alternative path
Make VBA unviewable
Methods expose mode
Application name
Copy protection with registration key
Hardware locking
Trial Mode
Freemium Mode
Registration key file name
Registration key alternative location
Custom resource dictionary
Menu Options
Menu Item – Project
The menu item “Project” includes choices which allow you to open, save, and create new VBA Compiler project files (files with the “.vbcprj” extension) . These project files contain all of the options you have selected and allows you to store them between work sessions.
Menu Item – Compile
The “Compile” menu item starts the Excel file VBA code compilation process. When you have selected all of the options that you need for compilation, you can initiate the compilation process with the “Compile” menu item.
Menu item – RegKey Tool
The “RegKey Tool” menu item starts the “Registration Key Tool” – the tool for registration key creation. This menu item is only available in VBA Compiler that is registered with a Professional license.
Menu item – Preferences
The “Preferences” menu item opens dialog window to setup the Visual C compiler location path.
Compilation options
Excel file with VBA code
The text in the “Excel file with VBA” field should contain the complete path (path and name) to the Excel file with the VBA code you are going to compile into DLL. The VBA Compiler doesn’t modify your original Excel file. Instead, it will create a copy of your original file and then process that copy.
Single file result (Embedded DLL)
By selecting this option, you can generate a single file as the output of the compilation process. The compiled DLL file or files will automatically be embedded within the compiled workbook or add-in.
The compiled file will keep the same extension as the original file. When launching the compiled workbook, the enabled DLL will be extracted and saved alongside the compiled workbook or add-in. This option is available in the product registered with the Professional license.
Disallow to run on virtual machines
By selecting this option, you prevent the execution of a compiled workbook or add-in on virtual machines. This option is available in the product registered with the Professional license.
Target Excel Bitness
The radio buttons designated as “32 bit”, “64 bit”, and “Both 32 & 64 bit” give a choice of a targeted Excel platform of the compiled VBA code.
The Excel can only load a Windows DLL file which is compatible with Excel’s bitness. So, Excel 32-bit can only load DLL files compiled for 32-bit. 64-bit Excel can only load DLL files compiled for 64-bit. You have to decide what Excel bitness you require. To make such a decision, you need to figure out which Excel bitness your customer has. To figure out which bitness your current Excel is under, follow this path: go to Excel Main Menu >> File >> Account >> About Excel button. In the About Excel box you may find the bitness of the currently loaded version of Excel in the first line:
In order to cover both cases, we suggest that you compile your VBA code into 2 versions, the 32 bit and the 64 bit, and allow to the customer select what version they need according to their own Excel bitness. The product allows for cross-bitness compilation. So, if you have Excel 32-bit you also can compile for Excel 64-bit and vice versa.
The option “Both 32 & 64 bit” is available in the product registered with the Professional license. This option allows for the compilation of VBA code for both 32 and 64 bit Excel. The output in this case will be 3 files: the workbook or Excel add-in with the connective VBA code, and 2 DLL files – one for Excel 32-bit another for Excel 64 bit. You need to supply all 3 files as well as the workbook which will load the DLL with the appropriate bitness for the currently available Excel bitness.
Output folder
The Path to the folder where the target compiled DLL file and the modified Excel workbook or add-in file will be located.
If you left this field empty, then the VBA Compiler will suggest you to use an automatically created sub-folder with a name of “VbaCompiledFiles” as the output folder for your compiled files.
Work folder
The “work folder” option defines the path to the folder where all temporarily and intermediate files will be located during compilation process. This option should be used to reduce the antivirus false positive detections that may arise during the compilation process. To achieve this, you need to set the “work folder” option and input this folder path into the antivirus exception list.
Backend C compiler
The VbaCompiler for Excel allows to select backend C compiler between MinGW GCC C compiler and Microsoft Visual C compiler in case if the product registered with Professional license.
C compiler optimization options
The VBA Compiler uses MinGW GCC C compiler as the backend C compiler to generate the final DLL file. The C compiler has a powerful optimization mechanism which improves the performance of the compiled code and reduces the size of the compiled DLL file.
The following is a list of available options:
- -O0 (no optimization)
- -O1 (optimize minimally) – default
- -O2 (optimize more)
- -O3 (optimize even more)
- -Ofast (optimize very aggressively, to the point of breaking standard compliance)
- -Os (Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.
In some situations, the GCC C compiler may generate over-optimized code with a high level of optimization setting (-O2 and higher). This code can become unstable and can crash during run-time. If you detect a run-time crash after compiling with such a high level of optimization, then you need to recompile your VBA code with a lower level of optimization (-O0 or -O1). The “-O1” level of optimization is used by default.
In case if you have selected the Visual C as backend C compiler then the optimization option values will be different:
- O1 sets a combination of optimizations that generate minimum size code.
- O2 sets a combination of optimizations that focuses on maximum speed for the resulting code.
- Od disables optimization, which can be used to speed up compilation and simplify debugging.
- Oi generates intrinsic functions for appropriate function calls.
- Os tells the compiler to favor optimizations for size over optimizations for speed.
- Ot (the default setting) tells the compiler to favor optimizations for speed over optimizations for size.
- Ox is a combination option that selects several of the optimizations with a particular emphasis on speed. /Ox is a strict subset of the /O2 optimizations.
- Oy suppresses the creation of frame pointers on the call stack for quicker function calls.
Author contact
This field should be filled out with the author’s e-mail address or a full web link (started with https:// or http:// prefixes) which leads to the author’s website. This contact information will be shown in the case that your customer clicks the “Contact Author” button in the custom messages section during run-time.
The following image is an example of such a situation. The message on the image appears when the VBA code is compiled with the “Copy protection with the registration key” and “Hardware lock” options, but the application cannot find the registration key.
The “Author contact” field is available in the registered version of the product. The registration email is used as the default value for this option, but you can overwrite it with another value should you wish to do so.
Compiled DLL file information group
This group contains two fields which allows you to define the DLL file version number as well as the DLL file copyright.
This information will be available in the compiled DLL file Properties >> Details tab.
DLL alternative path
The “DLL alternative path” option is only available in the VBA Compiler that is registered with a Professional license.
The DLL alternative path field defines the alternative (but not default) location of the compiled DLL.
By default, the DLL must be in the same folder as the Excel file that contains the connective VBA code.
If you have defined a “DLL alternative path” during compilation, then–upon start up–the compiled file will look for the DLL in the same location as the workbook; if the DLL is not found then the workbook will search for the DLL in the “DLL alternative path” that you have provided.
This feature allows you to point to a direct path (like “C:\MySpecialFolder\SubFolder”) as well as the use of the following templates: <?DOCUMENTS?>, <?COMMON_DOCUMENTS?>, <?PROGFILES?>, <?PROGFILESX86?>, <?WBKPATH?>.
These templates will be substituted by folder paths on the customer’s computer when the Excel file with the compiled VBA code is opened in the following manner:
<?DOCUMENTS?> – points to the current user’s Documents folder on the computer
<?COMMON_DOCUMENTS?> – points to the “All Users\Documents” folder on the computer
<?PROGFILES?> – points to the “Programs Files” (for 64-bit compilation) or “Program Files (x86)” (for 32-bit compilation) folder, depending on the bitness of the compilation.
<?PROGFILESX86?> – points to the “Program Files” folder on a 32 bit Windows and to the “Program Files (x86)” folder on a 64 bit Windows.
<?WBKPATH?> – points to the current workbook location in run-time, the same as the ThisWorkbook.Path value.
To use a template based path, you need to enter the text similar to this:
“<?DOCUMENTS?>\Application”
in this example, the location of the DLL on your customer’s computer will be as follows:
“C:\Users\CurrentUserName\Documents\Application”.
Make VBA unviewable
This feature is only available in the registered version of the product.
When you enable the “Make VBA unviewable” option, the VBA Compiler makes the VBA Project unviewable in the compiled Excel file. When the customer tries to look at the VBA code of the compiled file, they will see the following message:
This is protection from an accidental modification of the generated VBA code that may be potentially be done by the customer. The option was provided only as a feature of comfort that assists in the process of using the product. You may also use the VBA password protection instead of this option and apply the VBA Project password in the compiled Excel file.
Methods expose mode
The ‘Method expose mode’ option is available in VbaCompiler for Excel under the Professional license.
The option allows you to control the accessibility of the connective VBA methods.
The ‘All’ mode is used by default in all situations, even when this option is not available–such as in the Trial mode and in the product registered with a Standard license.
In this mode all VBA method wrappers of compiled VBA code are available from the VBA code.
The mode ‘Public’ does not expose method wrappers which have the access modifier set to ‘Private’ in the original VBA code. The event handler methods are the exception. All event handlers will be exposed in connective VBA code whether the access modifier is set to ‘Private’ or not.
The mode ‘None’ does not expose any methods to the connective VBA code. The same exceptions are applied–all event handlers are still exposed into connective VBA code. In the case of the usage of the ‘None’ mode, you need to control accessibility of some methods with the attribute [DNXVBC_VBA_EXPOSED_METHOD].
You need to insert this attribute as the first line of the method definition in the original VBA code for methods which you want to access from VBA code after compilation.
Private Function ExampleFunc()
[DNXVBC_VBA_EXPOSED_METHOD]
Sheet1.range("D2") = Empty
ExampleFunc = foo()
End Function
The same attribute may be used to make VBA methods inaccessible from VBA code after compilation. In this case you need to use it like [DNXVBC_VBA_EXPOSED_METHOD=False] in your original VBA code.
Public Sub SecretProc()
[DNXVBC_VBA_EXPOSED_METHOD=False]
Sheet1.range("D2") = Empty
End Sub
Application name
This is the name of your application, which will be used inside custom messages during run-time. Also, the content of the “Application name” field will be used as a link between the compiled VBA code and the registration key when you compile your VBA code with the “Copy protection with registration key” option toggled on.
Copy Protection with registration key
The “Copy protection with registration key” option is only available in the VBA Compiler registered with a Professional license.
The option enables copy protection with a registration/activation key. When you compile your Excel file VBA code and you have this option enabled, the file will not be able to start VBA without the registration key—which you must provide to the customer.
Hardware locking
The “Hardware locking” option is available only when the VBA compiler is registered with a Professional license.
The option enables a mode that allows the tying of a registration key to a specific computer in such a way that the compiled VBA code will only be able to work on that computer.
The process of tying a registration key to a specific computer is based on the “computer ID”. The computer ID is a unique number, represented in a readable way, which is generated by the VBA Compiler from the information gathered from some pieces of the hardware and some pieces of the software of the computer. The information is collected only for a moment of Computer ID generation and is never used in any other way. Besides, it is impossible to reconstruct the information about hardware and software that the computer ID came from. The unique Computer ID identifies the computer and will never match with any other computer ID generated from another computer.
The following is an example of a computer ID generated in this manner:
M5YN-J7XB-MB9M-EIMM-ZYI9D-HQTAA
Trial mode
The Trial Mode option allows to create trial versions of your workbook with protected VBA code. The trial version is limited by the amount of days that you set in the Trial Version options window.
After the trial period expires, the only way to run a protected workbook is to provide a registration key for such a workbook.
Freemium mode
The Fremium mode allows for the creation of compiled versions of your workbook which will work for an unlimited amount of time without registration. Freemium mode is the opposite of Trial mode. The workbook compiled with the ‘Freemium mode’ option shows a nag window on each start until the registration key is applied.
Registration key file name
You may change registration key file name used by default.
Registration key alternative location
The alternative path for registration key option may be used when the VBA code is compiled with the “Copy protection with registration key” option.
If registration key alternative path is set, then the registration key will be searched for in the default location (in the folder where DLL file with compiled VBA code is located), and if the registration key is not present in the default location then it will be searched for in the location mentioned in the alternative folder option.
This feature allows you to point to a direct path (like “C:\MySpecialFolder\SubFolder”) and it allows the use of templates: <?DOCUMENTS?>, <?COMMON_DOCUMENTS?>, <?PROGFILES?>, <?PROGFILESX86?>.
Custom resource dictionary
The custom resource dictionary allows for the translation or customizion of the content of the messages which are shown to a customer during run time. The examples of such dictionaries are present in the ‘rsc’ sub-folder in the VbaCompiler for Excel installation folder.