|
| 1 | +[](https://coveralls.io/github/Beakerboy/VBA-Precompiler?branch=main)  |
1 | 2 | # VBA-Precompiler |
2 | | -Precompile VBA source files with specified environment values. |
| 3 | + |
| 4 | +## About |
| 5 | +The Microsoft VBA language includes a simple precompilation language (Conditional Compilation). This tool allows users to specify environment parameters to convert a conditional-module-body into a preprocessed-module-body. |
| 6 | + |
| 7 | +This software operates as recommended in the [Microsoft VBA Language Specification](https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-CFB/%5bMS-CFB%5d.pdf). |
| 8 | + |
| 9 | +## Requirements |
| 10 | +vba_precompiler is tested on python 3.8 and higher. |
| 11 | + |
| 12 | +## Installation |
| 13 | +Use the package manager [pip](https://pip.pypa.io/en/stable/) to install VBA-Precompiler. |
| 14 | +``` |
| 15 | +pip install 'php_precompiler @ git+https://github.com/Beakerboy/VBA-Precompiler@dev |
| 16 | +``` |
| 17 | + |
| 18 | +## Getting Started |
| 19 | +vba_precompiler will take a specified directory that contains vba source code, and a set of environment values, and produce a set of matching vba source files in which code is excluded as directed by the precomiler directives. |
| 20 | + |
| 21 | +For example, the following |
| 22 | +``` |
| 23 | +Attribute VB_Name = "Input" |
| 24 | +#Const TestType="testing" |
| 25 | +#If Win16 Or Then |
| 26 | + foo = 6 |
| 27 | +#ElseIf Win32 |
| 28 | + foo = 7 |
| 29 | +#EndIf |
| 30 | +'Additional VBA code follows |
| 31 | +``` |
| 32 | + |
| 33 | +Will be transformed to the following: |
| 34 | +``` |
| 35 | +Attribute VB_Name = "Input" |
| 36 | +'#Const TestType="testing" |
| 37 | +'#If Win16 Then |
| 38 | + foo = 6 |
| 39 | +'#ElseIf Win32 |
| 40 | +' foo = 7 |
| 41 | +'#EndIf |
| 42 | +'Additional VBA code follows |
| 43 | +``` |
| 44 | +To run the program |
| 45 | +``` |
| 46 | +python vba_precompiler.py [-h] [-s SYSTEM] [-v VERSION] [-o OUTPUT] directory |
| 47 | +
|
| 48 | +positional arguments: |
| 49 | + directory The source directory. |
| 50 | +
|
| 51 | +options: |
| 52 | + -h, --help show this help message and |
| 53 | + exit |
| 54 | + -s, --system System Type, Win16, Win32, Win64, or Mac. |
| 55 | + -v, --version VBA version, 6 or 7. |
| 56 | + -o, --extract output path, defaults to ./build. |
| 57 | +
|
| 58 | +examples: |
| 59 | + python -m vba_precompiler -s Win32 -v 7 -o ./build32_7 ./project |
| 60 | +``` |
| 61 | + |
| 62 | +## Tests |
| 63 | +The tests directory contains complete unit and functional tests. |
| 64 | + |
| 65 | +## Contributing |
| 66 | +Contributions are welcome. Please ensure new features include unit tests to maintain 100% coverage. All code must adhere to the [PEP8 Standards](https://peps.python.org/pep-0008/) for both formatting and naming. Method signatures must be fully annotated. |
0 commit comments