Enable seamless MS Office VBA code editing in preferred editor or IDE (facilitating the use of coding assistants and version control workflows)
Project description
Enable seamless Microsoft Office VBA code editing in your preferred editor or IDE, facilitating the use of coding assistants and version control workflows.
Features
Edit VBA code in your favorite code editor or IDE
Automatically sync changes between your editor and Office applications
Support for Word, Excel, and Access (PowerPoint support coming in v0.4.0)
Preserve form layouts and module properties
Handle different character encodings
Integration with version control systems
Support for UserForms and class modules
Quick Start
Installation
pip install vba-edit
Prerequisites
Enable “Trust access to the VBA project object model” in your Office application’s Trust Center Settings:
Open your Office application
Go to File > Options > Trust Center > Trust Center Settings
Select “Macro Settings”
Check “Trust access to the VBA project object model”
Basic Usage
Excel Example
Open your Excel workbook with VBA code
In your terminal, run:
excel-vba edit
Edit the exported .bas, .cls, or .frm files in your preferred editor
Changes are automatically synced back to Excel when you save
Word Example
# Export VBA modules from active document
word-vba export --vba-directory ./VBA
# Edit and sync changes automatically
word-vba edit --vba-directory ./VBA
# Import changes back to document
word-vba import --vba-directory ./VBA
Access Example
# Export VBA modules
access-vba export --vba-directory ./src
# Import changes
access-vba import --vba-directory ./src
Detailed Features
Supported File Types
Standard Modules (.bas)
Class Modules (.cls)
UserForms (.frm)
Document/Workbook Modules
Command Line Tools
The package provides separate command-line tools for each Office application:
word-vba
excel-vba
access-vba
Each tool supports three main commands:
edit: Live sync between editor and Office (Word/Excel only)
export: Export VBA modules to files
import: Import VBA modules from files
check: Check if ‘Trust Access to the VBA project object model’ is enabled
Common Options
--file, -f Path to Office document (optional)
--vba-directory Directory for VBA files
--encoding, -e Specify character encoding
--detect-encoding, -d Auto-detect encoding
--save-headers Save module headers separately
--verbose, -v Enable detailed logging
--logfile, -l Enable file logging
Excel-Specific Features
For Excel users who also have xlwings installed:
excel-vba edit -x # Use xlwings wrapper
Best Practices
Always backup your Office files before using vba-edit
Use version control (git) to track your VBA code
Run export after changing form layouts or module properties
Use --save-headers when working with UserForms
Consider using --detect-encoding for non-English VBA code
Known Limitations
Access support is limited to import/export (no live editing)
UserForms require --save-headers option
PowerPoint support coming in v0.4.0
--in-file-headers option coming soon
Links
Video Tutorial (xlwings walkthrough, with similar functionality)
License
BSD 3-Clause License
Acknowledgments
This project is heavily inspired by code from xlwings vba edit, maintained by the xlwings-Project under the BSD 3-Clause License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file vba_edit-0.3.0.tar.gz
.
File metadata
- Download URL: vba_edit-0.3.0.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31db751c1454e32c8dae511422c49d8cb7b745304822bb294eb1e2932e726620 |
|
MD5 | cf44f0d8205f2094ae2d544071724939 |
|
BLAKE2b-256 | 5544c0b59566aacb42d32564370abf7bdfda5034fb08eb8befb713abbe2caad8 |
File details
Details for the file vba_edit-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: vba_edit-0.3.0-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1d6aaa0630231c4bcb46f301c269c1064a0869af9364ff760d3245394060f21 |
|
MD5 | 6845c3a779d122339ccead712ec08a37 |
|
BLAKE2b-256 | 13d78678e9d4a8f427063065f0c3a1e1eed702bf59e653fe7cde55d7461a8a9f |