English | Русский
Tool: MACROTools v2.0 Class:
clsObfuscatorLaunch Module:modToolsObfuscationVersion: 2.0.38
- What is Obfuscation
- Why Obfuscation is Needed
- Preparation for Obfuscation
- Running Obfuscation
- Obfuscation Stages
- Obfuscation Results
- OBFUSCATION_VARIABLE Settings Sheet
- What Gets Obfuscated
- What Does NOT Get Obfuscated
- Recovery and Debugging
⚠️ 🚨Limitations and Warnings ← CRITICALLY IMPORTANT SECTION!- Frequently Asked Questions
Obfuscation is the process of transforming source code into a form that preserves its functionality but makes understanding, analysis, and modification difficult.
When obfuscating a VBA project:
- ✅ Identifiers (variable, procedure, module names) are replaced with generated names
- ✅ String literals are extracted to a separate constants module
- ✅ Ribbon XML callbacks are replaced with generated names
- ✅ A report of all performed replacements is created
- ✅ Code functionality is fully preserved
- Hides algorithm logic
- Makes reverse engineering difficult
- Protects commercial solutions
- Variables get names like
O01l1l01l1l0 - Procedures are renamed to
O01l1l01l1l0 - Modules get names
O01l1l01l1l0
-
Access to VBA Project
- Project must not be password protected
- VBA object model access is enabled:
- Excel → File → Options → Trust Center → Macro Settings → ✅ Trust access to the VBA project object model
-
Backup Copy
⚠️ Obfuscation is irreversible!- Always create a file copy before running
- The add-in automatically creates a backup, but additional protection doesn't hurt
-
Testing
- Test obfuscation on a file copy
- Ensure code works after obfuscation
- Check all macros bound to buttons and shapes
Before running obfuscation, you need to collect data about the VBA project:
-
Open the target Excel workbook
-
In MACROTools select: Tools → Collect Data for Obfuscation
-
The add-in will create an
OBFUSCATION_VARIABLEsheet with data:- Modules and their code
- Procedures and functions
- Variables and constants
- UserForm controls
- Declarations
-
Verify data on the sheet:
- Ensure all elements are collected correctly
- Edit the list if necessary
- Check element types (
TypeElement) - Exclude variables you don't want to obfuscate by removing them from the list
- Open Excel with MACROTools add-in loaded
- Go to the MACROTools tab in the Ribbon
- Click the Obfuscate VBA Project button (
btnObfuscator) - Select the target workbook (if multiple are open)
- Wait for the process to complete
- Open Visual Basic Editor (
Alt+F11) - In the context menu select Tools → Obfuscate VBA Project
- Confirm the action
Sub RunObfuscation()
Call ObfuscationVBAProject
End SubDuring obfuscation:
- 🔄 Screen updating is disabled (
ScreenUpdating = False) - 🔄 Alerts are disabled (
DisplayAlerts = False) - 🔄 A backup copy of the file is created
- 🔄 Obfuscation stages are executed sequentially
- 🔄 A report is generated on the
OBFUSCATION_REPORTsheet
Obfuscation is performed in 9 stages:
What happens:
- All string values are extracted from code
- A new
modLiteralsmodule is created with constants - Strings in the source code are replaced with references to constants
Example:
' Before:
MsgBox "Hello, World!"
' After:
MsgBox O01l1l01l1l0 ' where O01l1l01l1l0 = "Hello, World!"What happens:
- Local variables inside procedures are renamed
- Procedure parameters are renamed
- Local constants are renamed
Example:
' Before:
Dim userName As String
userName = "John"
' After:
Dim O01l1l01l1l0 As String
O01l1l01l1l0 = "John"What happens:
- All controls on UserForm are renamed
- References in form code are updated
- References in all project modules are updated
Example:
' Before:
TextBox1.Value = "Test"
' After:
O01l1l01l1l0.Value = "Test"What happens:
- All procedures and functions are renamed
- Calls in all modules are updated
- Macros bound to shapes are processed
- Ribbon UI callbacks are processed
Example:
' Before:
Sub CalculateTotal()
' ...
End Sub
' After:
Sub O01l1l01l1l0()
' ...
End SubWhat happens:
- Module-level variables are renamed
WithEventsdeclarations are processed- References to classes with events are updated
What happens:
- All modules get new names
- Standard modules →
OXXXXXXXXXXXX - Classes →
OXXXXXXXXXXXX - UserForms →
OXXXXXXXXXXXX
Example:
' Before:
modTools.bas
clsHelper.cls
UserForm1.frm
' After:
O01l1l01l1l0.bas
O01l1l01l1l1.cls
O01l1l01l1ll.frm
What happens:
- UserForm interface changes are saved
- Control properties are updated
What happens:
- Modified code is written to VBComponents
- Modules are renamed in VBA project
- Project is saved
What happens:
OBFUSCATION_REPORTsheet is created- All correspondences are recorded: New name → Original value
- Complete obfuscation map is formed
After obfuscation is completed, a report sheet is created:
| Column | Description |
|---|---|
| A | Element type (Literals, Module, Procedure, etc.) |
| B | Element subtype |
| C | Additional information |
| D | Module name |
| E | New obfuscated name |
OBFUSCATION_REPORT
├── Literals.<ModuleName>.<StringValue> → OXXXXXXXXXXXX
├── Module.<ModuleName> → OXXXXXXXXXXXX
├── Procedure.<ModuleName>.<ProcName> → OXXXXXXXXXXXX
├── Declaration.<ModuleName>.<VarName> → OXXXXXXXXXXXX
├── Local Variable.<Module>.<Proc>.<VarLines> → OXXXXXXXXXXXX
└── UserForm.<Module>.<ControlName> → OXXXXXXXXXXXX
- File is automatically saved after obfuscation
- Backup copy is created before starting
⚠️ It is recommended to immediately verify functionality
The OBFUSCATION_VARIABLE sheet contains information about the VBA project:
| Column | Data | Description |
|---|---|---|
| A | TypeElement | Element type (Module, Procedure, Declaration, etc.) |
| B | ModuleName | Module name |
| C | ModuleType | Module type (Standard, Class, UserForm) |
| D | ProcName | Procedure/variable name |
| E | ProcType | Type (Function, Sub, WithEvents, etc.) |
| F | ProcLines | Line numbers or identifier |
| G | ProcDeclaration | Procedure declaration |
| H-J | Additional data | Internal parameters |
| Type | Description |
|---|---|
Module |
Standard module, class, or UserForm |
Procedure |
Procedure or function |
Declaration |
Module-level variable declaration |
UserForms |
Control on UserForm |
Parametr |
Procedure parameter |
Local Variable |
Local variable |
Local Const |
Local constant |
If you changed the code after collecting data:
- Delete the
OBFUSCATION_VARIABLEsheet - Run: Tools → Collect Data for Obfuscation
- Data will be collected again
| Element | Example | Result |
|---|---|---|
| String literals | "Hello" |
O7A3B9C2D1E5 |
| Local variables | Dim x As Long |
Dim O4F8A2C9D3E7 As Long |
| Procedure parameters | Sub Test(name As String) |
Sub Test(O2D7E4A1B8C3 As String) |
| Procedures | Sub CalculateTotal() |
Sub O9B3C6D2E5A1() |
| Functions | Function GetValue() |
Function O5A9B2C7D3E1() |
| Module variables | Private m_count As Long |
Private O3F7C2D8E5A1 As Long |
| UserForm controls | TextBox1 |
O2D7E4A1B8C3 |
| Modules | modTools |
O5A9B2C7D3E1 |
| Classes | clsHelper |
O8D4E1A6B9C2 |
| UserForms | UserForm1 |
O3F7C2D8E5A1 |
| WithEvents | WithEvents App As Application |
WithEvents O1C5D9E3A7B2 As Application |
- Procedure calls in all modules
- Control event handlers
- Macros bound to shapes
- Ribbon UI callbacks
- References to classes with events
| Name | Reason |
|---|---|
Class_Initialize |
System class constructor |
Class_Terminate |
System class destructor |
Auto_Open |
Automatic workbook opening |
Auto_Close |
Automatic workbook closing |
| Name | Example |
|---|---|
| Workbook events | Workbook_Open, Workbook_SheetChange |
| Worksheet events | Worksheet_Change, Worksheet_Activate |
| UserForm events | UserForm_Initialize, UserForm_Click |
' NOT obfuscated:
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
' Event name is preserved
End Sub- Windows API calls (
Declare Function) - References to external libraries
- Built-in VBA function names
Only strings in VBA code are obfuscated, not in cell formulas.
IMPORTANT: Obfuscation is IRREVERSIBLE automatically.
-
From backup copy
- Use the automatically created file copy
- Or your manual backup copy
-
Via report sheet
OBFUSCATION_REPORTsheet contains correspondence map- Column E → new name
- Columns A-D → original description
- Names can be restored manually
-
Via OBFUSCATION_VARIABLE
- Settings sheet contains original names
- Use as a reference
- ❌ Variable names are non-informative
- ❌ Code tracing is difficult
- ❌ Immediate window shows
OXXXXXXXXXXXX
-
Debug the NON-obfuscated version
- Always keep the original
- Develop in the original
- Obfuscate only for distribution
-
Use the report sheet
- Open
OBFUSCATION_REPORT - Find the needed new name in column E
- Determine original purpose
- Open
-
Comment code BEFORE obfuscation
- Add detailed comments
- Comments are removed during obfuscation
- This will help understand logic later
-
Keep a change log
- Record what and why you obfuscated
- Save the version before obfuscation
-
Variable Name Conflicts with Object Properties
⚠️ If a variable name matches an object property name, obfuscation may mistakenly replace the property- Problem Example:
' Before obfuscation: Public Sub example() Dim oList As MSForms.ListBox Dim Value As String Debug.Print oList.Value = "value" End Sub ' ❌ After obfuscation (INCORRECT): Public Sub example() Dim oList As MSForms.ListBox Dim o01010l01l01l0 As String Debug.Print oList.o01010l01l01l0 = "value" ' ← Error: .Value property replaced End Sub
- Solution: Rename the variable so it doesn't match object properties:
' ✅ Correct version (variable sValue instead of Value): Public Sub example() Dim oList As MSForms.ListBox Dim sValue As String Debug.Print oList.Value = "value" End Sub ' ✅ After obfuscation (CORRECT): Public Sub example() Dim oList As MSForms.ListBox Dim o01010l01l01l0 As String Debug.Print oList.Value = "value" ' ← .Value property preserved End Sub
- Recommendation: Use prefixes for variable names:
sValue,sName,sPath(strings)lCount,lIndex,lTotal(Long numbers)bFlag,bEnabled,bVisible(booleans)oObject,oList,oRange(objects)
-
VBA Project Password
- ❌ Obfuscation does not work with protected projects
- Remove protection before running
-
Irreversibility
⚠️ No automatic rollback- Always create a backup copy
-
Complex Projects
⚠️ Large projects may take a long time to process- Recommended to test on a copy
-
API Calls
⚠️ Some functions use API hooks- Additional configuration may be required
-
References to Other Projects
⚠️ External references are not obfuscated- Check compatibility after obfuscation
| Problem | Solution |
|---|---|
| Late Binding objects | May not obfuscate correctly |
| Dynamic control creation | Check after obfuscation |
| CallByName calls | String names are not updated automatically |
| Evaluate() with procedure names | May require manual editing |
- Obfuscated code is protected from reading, but not from execution
- For full protection, additionally use Unviewable VBA Project
- Obfuscation makes reverse engineering difficult, but not impossible
No. Obfuscation does not affect performance. Only names are changed, logic remains the same.
Yes. Edit the OBFUSCATION_VARIABLE sheet before running — delete rows that you don't want to obfuscate.
- Check the log:
...\AppData\Roaming\Microsoft\AddIns\MACROTools_logs.csv - Ensure the VBA project is not password protected
- Check data correctness on the
OBFUSCATION_VARIABLEsheet - Try on a simple test workbook
No. Obfuscation is performed for one workbook at a time. Repeat the process for each.
No. Comments are removed.
Yes. References to macros in shapes and controls are updated automatically.
- Run all main macros
- Check UserForms
- Test buttons and shapes
- Check Ribbon UI callbacks
- Ensure events are working
Recommended:
- ✅ Save a copy of the file with report sheets
- ✅ Delete sheets from the final version for security
- ✅ Or hide sheets:
xlSheetVeryHidden
Yes. Use:
Sub ObfuscateTargetWorkbook()
Dim wb As Workbook
Set wb = Workbooks("TargetBook.xlsm")
If wb.VBProject.Protection = vbext_pp_locked Then
MsgBox "Project is protected!", vbCritical
Exit Sub
End If
Dim oObs As Object
Set oObs = CreateObject("clsObfuscator")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
If oObs.Execute(wb) Then
MsgBox "Success!", vbInformation
Else
MsgBox "Failed!", vbExclamation
End If
Set oObs = Nothing
End Sub- MODULES_REFERENCE_ENG.md — Reference of all MACROTools modules
- clsObfuscator.cls — Obfuscator class source code
- modToolsObfuscation.bas — Obfuscation launch module
If you experience problems:
-
Check the log file:
...\AppData\Roaming\Microsoft\AddIns\MACROTools_logs.csv -
Ensure VBA access is allowed
-
Restart Excel and check add-in activation
-
Test only on file copies
Apache License Author: VBATools Add-in Version: v2.0.38
⚠️ Remember: Obfuscation is a tool to protect against accidental code reading, not against targeted hacking. Use comprehensive protection measures for critically important projects.