Pure-Python reader/writer for VBA macros embedded in Excel / PowerPoint / Word / Access files. Zero dependencies, deterministic round-trip, safe on protected and signed projects.
HEALTH ? 100 / Healthy
// readme
pyOpenVBA
Read and write the code inside Office files, in pure Python: VBA macros in four hosts, and Power Query in Excel.
No dependencies beyond the standard library. No Office install needed. Works on Windows, macOS and Linux. Python 3.10 or newer.
VBA, four hosts and one API:
- Excel (
.xlsm,.xlsb,.xlam,.xls;.xltm,.xlt,.xlaread only) - Word (
.docm,.dotm,.doc;.dotread only) - PowerPoint (
.pptm,.potm,.ppt;.ppsm,.ppamread only) - Access (
.accdb,.mdb)
Power Query, in any Excel package:
from pyopenvba import PowerQueryWorkbook
with PowerQueryWorkbook("orders.xlsx") as book:
print(book.query_names())
book.query("Orders").formula = "let Source = Excel.CurrentWorkbook() in Source"
book.save()
Why use this?
Good Python tools exist for reading VBA out of Office files (oletools, olefile and friends), and they remain the right choice for forensics, malware analysis and audits. pyOpenVBA covers the next step: writing changes back so the file still opens cleanly in the host application.
The write path is the point of the library:
- Modify a module’s source in place.
- Add a standard…