VBA Compiler Options
Excel file with VBA
Target Excel bitness
C compiler optimization options
DLL alternative path
Make VBA unviewable
Copy protection with registration key
Menu Item – Project
The menu item “Project” includes choices which allow you to open, save, and create new VBA Compiler project files (files with “.vbcprj” extension) . These project files contain all of the options you have selected and store them between product 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.
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.
Target Excel Bitness
The radio buttons designated as “32 bit” and “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 need. 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 compile your VBA code to 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 to make cross bitness compilation. So, if you have Excel 32-bit you also can compile for Excel 64-bit and vice versa.
The Path to the folder where the target compiled DLL file and modified Excel workbook or add-in file will be locate.
If you left this field empty, then the VBA Compiler will suggest you to use automatically created sub-folder with a name of “VbaCompiledFiles” as the output folder for your compiled files.
C compiler optimization options
The VBA Compiler uses MinGW GCC C compiler as the backend compiler to generate the final DLL file. The C compiler has a powerful optimization mechanism which improves performance of the compiled code and reduces the size of the compiled DLL file.
The list of available options is:
- -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 level of optimization of “-O1” is used by default.
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 custom messages 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 a registered version of the product. The registration email is used as default value for this option, but you can overwrite it with another value you wish.
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 with the compiled VBA code.
If you have defined a “DLL alternative path” during compilation, then, on start, the compiled file will look for the DLL in the same location that the workbook is located; if the DLL is not found the workbook will search for the DLL in the “DLL alternative path” that you have pointed to.
This feature allows you to point to a direct path (like “C:\MySpecialFolder\SubFolder”) as well as the use of templates: <?DOCUMENTS?>, <?COMMON_DOCUMENTS?>, <?PROGFILES?>, <?PROGFILESX86?>.
Where templates will be substituted by folder paths on the customer’s computer when the Excel file with the compiled VBA code is opened as follows:
<?DOCUMENTS?> – points to the current user 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 compilation.
<?PROGFILESX86?> – points to the “Program Files” folder on Windows 32 bit and to the “Program Files (x86)” folder on Windows 64 bit.
To use a template based path, you need to enter the string something like:
in this example, the location of the DLL on your customer computer will be as follows:
Make VBA unviewable
This feature is available in only 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 use VBA Project password protection instead of this option and apply the VBA Project password in the compiled Excel file.
The name of your application which will be used in the 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.
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 from another computer.
The following is an example of a computer ID generated in this manner: