excel-vba-workbook-engineering
Skill2 starsChanged 5 months agoMITView on GitHub
Use when creating, modifying, or debugging .xlsx/.xlsm/.xlsb/.xls workbooks, VBA modules, macros, buttons, formulas, links, Power Query, or Excel COM/OpenXML automation.
In this repository36 other files it gives its agents.
- AGENTS.mdAGENTS.md
- excel-ado-sql-data-accessSkill
- excel-bi-routerSkill
- excel-deliverable-publisherSkill
- excel-report-builderSkill
- excel-testing-fixturesSkill
- excel-vba-workbook-engineeringSkill
- excel-workbook-qa-auditorSkill
- mdx-cubevalue-extractionSkill
- office-environment-diagnosticsSkill
- power-bi-semantic-modelSkill
- power-pivot-dax-modelingSkill
- power-query-m-engineeringSkill
- excel-ado-sql-data-accessSkill
- excel-bi-routerSkill
- excel-deliverable-publisherSkill
- excel-report-builderSkill
- excel-testing-fixturesSkill
- excel-vba-workbook-engineeringSkill
- excel-workbook-qa-auditorSkill
- mdx-cubevalue-extractionSkill
- office-environment-diagnosticsSkill
- power-bi-semantic-modelSkill
- power-pivot-dax-modelingSkill
- power-query-m-engineeringSkill
- excel-ado-sql-data-accessSkill
- excel-bi-routerSkill
- excel-deliverable-publisherSkill
- excel-report-builderSkill
- excel-testing-fixturesSkill
- excel-workbook-qa-auditorSkill
- mdx-cubevalue-extractionSkill
- office-environment-diagnosticsSkill
- power-bi-semantic-modelSkill
- power-pivot-dax-modelingSkill
- power-query-m-engineeringSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
29 rules. About 0 are common, 10 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Treat Excel/VBA work as a binary-artifact engineering task.
- Very specific: line 14
Windows desktop Excel available: Use Excel COM automation for the highest-fidelity workflow.
- Very specific: line 16
Workbook without VBA: Prefer structured workbook tools or Python/JS libraries for .xlsx analysis, formula inspection, formatting, and data …
- Very specific: line 18
Workbook depends on Excel-only features: Use live Excel for Solver, Power Query refresh, cube formulas, data model, macro buttons, chart …
- Distinctive: line 35
If macros exist, export VBA components to a source folder before changing anything.
- Very specific: line 36
Use scripts/inspect_workbook.ps1 or scripts/invoke_excel_com.sh inspect when Windows Excel is installed.
- Very specific: line 37
Use scripts/inspect_openxml.py when running on Linux/macOS or when Excel is unavailable.
- Distinctive: line 42
Keep user-facing sheets clean.
- Very specific: line 47
Use .xlsm for macro-enabled deliverables.
- Very specific: line 48
Keep VBA in exported .bas, .cls, or .frm files under a source folder.
- Very specific: line 49
Use Option Explicit, clear public macro entry points, and late binding when references may be missing on another machine.
- Very specific: line 50
Do not paste exported Attribute VB_Name = "..." lines directly into the VBE code pane.
- Very specific: line 54
Prefer Form Control buttons or shapes with .OnAction = "MacroName" for simple workbooks.
- Very specific: line 55
Ensure the target macro is Public Sub MacroName() in a standard module.
- Very specific: line 56
When a deliverable depends on buttons, use the package-level tools/build_vba_button_binding_report.py with workbook inventory JSON and …
- Distinctive: line 57
Avoid ActiveX controls unless the workbook already uses them or the user requires them.
- Distinctive: line 62
Verify key output cells, formula errors, constraints, totals, and formatting.
- Very specific: line 64
Use package-level tools/build_workbook_controls_report.py with OpenXML inspection JSON to review hidden/very hidden sheets, workbook …
- Very specific: line 65
Use package-level tools/build_external_dependency_report.py with OpenXML inspection JSON before static or client handoff to flag workbook …
- Distinctive: line 66
Check that hidden sheets, links, queries, and buttons are in the intended final state.
- Distinctive: line 68
If working on Linux/macOS, state which validations were structural only and which still require Excel on Windows or Mac.
- Distinctive: line 78
Use this source layout for nontrivial VBA work:
- Very specific: line 93
Use scripts/export_vba.ps1 to export modules from an existing workbook.
- Very specific: line 97
Start hidden Excel instances with Visible = $false and DisplayAlerts = $false.
- Very specific: line 98
Always close workbooks and quit the COM Excel instance in finally.
- Very specific: line 100
Do not kill all EXCEL.EXE processes.
- Distinctive: line 101
Do not use destructive shell operations to move/delete workbook folders without verifying resolved paths.
- Very specific: line 106
Prefer ASCII VBA module source when possible.
- Distinctive: line 107
If Chinese literals are necessary, import and reopen the workbook to verify they survived.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Excel VBA Workbook Engineering
Core Rule
Treat Excel/VBA work as a binary-artifact engineering task. Inspect the workbook first, edit a copy unless the user explicitly asks otherwise, keep VBA source diffable outside the workbook, then verify by reopening the workbook and running the relevant macros or formula checks.
Decision Path
- Windows desktop Excel available: Use Excel COM automation for the highest-fidelity workflow. From PowerShell call the
.ps1scripts directly. From Git Bash callscripts/invoke_excel_com.sh, which converts paths and invokes PowerShell. - Linux/macOS or no Excel COM: Use OpenXML inspection and workbook libraries for
.xlsx/.xlsmstructure, formulas, styles, and data. Usescripts/inspect_openxml.pyfor a cross-platform JSON inventory. Do not claim that VBA can be compiled, buttons can be fully validated, Solver can run, or Power Query/data model can refresh without Excel. - Workbook without VBA: Prefer structured workbook tools or Python/JS libraries for
.xlsxanalysis, formula inspection, formatting, and data extraction. - Workbook with VBA or buttons: Export VBA components before editing when Excel COM is available. On Linux/macOS, preserve
vbaProject.binwhen editing.xlsm, but route final VBA import/compile/run validation to Windows Excel unless the user explicitly accepts manual validation. - Workbook depends on Excel-only features: Use live Excel for Solver, Power Query refresh, cube formulas, data model, macro buttons, chart objects, ActiveX/Form controls, hidden/very hidden sheets, and legacy
.xls. - VBA project access is blocked: Tell the user that Excel's "Trust access to the VBA project object model" setting is required for automated export/import. Continue with manual instructions or workbook-level non-VBA edits if possible.
Platform Matrix
| Environment | Best path | Can inspect | Can edit workbook | Can import/export VBA | Can compile/run VBA |
| Windows PowerShell + desktop Excel | Excel COM scripts | yes | yes | yes | yes |
| Windows Git Bash + desktop Excel | invoke_excel_com.sh wrapper | yes | yes | yes | yes |
| Linux/macOS without Excel | OpenXML/Python/library path | partial | yes for .xlsx/some .xlsm edits | no automated VBE export/import | no |
| Linux/macOS with LibreOffice | LibreOffice/library path | partial | partial | no VBE-compatible import/export | no reliable Excel VBA validation |
Required Workflow
- Inventory
- Record the input workbook path, file type, and whether it contains macros.
- List sheets, visible state, used ranges, formulas, names, shapes/buttons with
OnAction, links, queries, and connections. - If macros exist, export VBA components to a source folder before changing anything.
- Use
scripts/inspect_workbook.ps1orscripts/invoke_excel_com.sh inspectwhen Windows Excel is installed. - Use
scripts/inspect_openxml.pywhen running on Linux/macOS or when Excel is unavailable.
- Plan the workbook shape
- Decide which sheets are user-facing, calculation/support, hidden, or deleted.
- Decide which cells are inputs, formulas, outputs, and diagnostics.
- Keep user-facing sheets clean; hide support sheets only after validation.
- Preserve existing visual conventions unless the user asks for redesign.
- Edit safely
- Work on a copy by default. Never overwrite the only source workbook.
- Use
.xlsmfor macro-enabled deliverables. Saving as.xlsxstrips VBA. - Keep VBA in exported
.bas,.cls, or.frmfiles under a source folder. - Use
Option Explicit, clear public macro entry points, and late binding when references may be missing on another machine. - Do not paste exported
Attribute VB_Name = "..."lines directly into the VBE code pane; those lines are valid in exported files, not manual paste text.
- Bind UI
- Prefer Form Control buttons or shapes with
.OnAction = "MacroName"for simple workbooks. - Ensure the target macro is
Public Sub MacroName()in a standard module. - When a deliverable depends on buttons, use the package-level
tools/build_vba_button_binding_report.pywith workbook inventory JSON andlint_vba_source.pyJSON to statically catch stale or missingOnActionmacros before handoff. - Avoid ActiveX controls unless the workbook already uses them or the user requires them.
- Prefer Form Control buttons or shapes with
- Validate
- Reopen the saved copy in Excel.
- Compile VBA or run at least one representative macro.
- Verify key output cells, formula errors, constraints, totals, and formatting.
- For workbook deliverables with formulas, use package-level
tools/build_formula_quality_report.pywith OpenXML inspection JSON to flag cached formula errors,#REF!, local path references, volatile functions, and dynamic references before final handoff. - Use package-level
tools/build_workbook_controls_report.pywith OpenXML inspection JSON to review hidden/very hidden sheets, workbook protection, sheet protection, filters, frozen panes, and data validation rules before handoff. - Use package-level
tools/build_external_dependency_report.pywith OpenXML inspection JSON before static or client handoff to flag workbook connections, external links, external formulas, defined names, mashup/model markers, and credential-like connection string indicators without printing connection secrets. - Check that hidden sheets, links, queries, and buttons are in the intended final state.
- Save a short validation note or test output when the workbook is a deliverable.
- If working on Linux/macOS, state which validations were structural only and which still require Excel on Windows or Mac.
- For package maintenance, the full release gate creates a temporary
.xlsxworkbook and validatesscripts/inspect_workbook.ps1against live Excel COM inventory fields: worksheet, formula count, workbook name, button shape,OnAction, and named range. - The full release gate also imports a temporary VBA module into a
.xlsm, runs the imported macro, and exports the module back out to prove the live import/run/export path. The structural release gate intentionally skips these Excel runtime fixtures. - The release gate runs a static formula quality fixture so cached errors,
#REF!, local paths, volatile functions, and dynamic references are covered without customer workbooks. - The release gate runs a static workbook controls fixture so hidden/very hidden sheets, workbook/sheet protection, filters, frozen panes, and data validation are covered without customer workbooks.
- The release gate runs a static external dependency fixture so workbook connections, link parts, external formulas/names, mashup markers, and redacted credential-like connection string indicators are covered without customer workbooks.
- The release gate also cross-checks generic button
OnActionvalues against public VBA source entries so static button-to-macro binding drift is covered in both full and structural profiles.
VBA Source Discipline
Use this source layout for nontrivial VBA work:
project/
deliverables/
workbook_name.xlsm
src/
vba/
modMain.bas
modHelpers.bas
ThisWorkbook.cls
docs/
validation.mdUse scripts/export_vba.ps1 to export modules from an existing workbook. Use scripts/import_vba.ps1 to import standard/class/form modules into a workbook copy. From Git Bash, use scripts/invoke_excel_com.sh export and scripts/invoke_excel_com.sh import. Read references/vba-patterns.md before writing or replacing VBA.
Excel COM Safety
- Start hidden Excel instances with
Visible = $falseandDisplayAlerts = $false. - Always close workbooks and quit the COM Excel instance in
finally. - Release COM objects where practical.
- Do not kill all
EXCEL.EXEprocesses. The user may have visible workbooks open. Only stop a process you created and can identify. - Do not use destructive shell operations to move/delete workbook folders without verifying resolved paths.
Encoding And Localization
- VBA exported by the VBE is not a reliable UTF-8 interchange format on every Windows machine.
- Prefer ASCII VBA module source when possible. For Chinese sheet names or labels, either reference existing worksheet objects, use values read from the workbook, or build literals with
ChrW$. - If Chinese literals are necessary, import and reopen the workbook to verify they survived.
- In terminal validation, avoid relying only on displayed Chinese text because console encoding may garble it. Verify through counts, formulas, cell addresses, and numeric values too.
References
Load only the reference needed for the task:
references/workflow.md: detailed workbook/VBA workflow, validation checklist, and troubleshooting.references/vba-patterns.md: VBA coding patterns, macro button binding, Solver/automation notes, and common compile/runtime fixes.
Scripts
scripts/inspect_workbook.ps1 -WorkbookPath <path> [-OutJson <path>]creates a JSON inventory through Excel COM.scripts/invoke_excel_com.sh inspect|export|import ...runs the Excel COM scripts from Git Bash/MSYS/Cygwin on Windows.scripts/inspect_openxml.py <workbook> [--out-json <path>]creates a cross-platform OpenXML inventory for.xlsx/.xlsmwithout Excel.scripts/export_vba.ps1 -WorkbookPath <path> -OutDir <folder>exports VBA components for review/editing.scripts/import_vba.ps1 -WorkbookPath <path> -SourceDir <folder> -OutputWorkbookPath <path>copies a workbook and imports VBA modules from a source folder.scripts/lint_vba_source.py <source-dir> [--strict-option-explicit] [--out-json <path>]statically checks exported or drafted.bas,.cls, and.frmfiles for parseable procedure blocks, duplicate public standard-module entry points, and missingOption Explicitbefore import.
These scripts are helpers, not substitutes for judgment. Read or patch them when a workbook has special requirements.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

