90le/microsoft-excel-bi-agent/excel-vba-workbook-engineering
Claude Code and agent skill by 90le/microsoft-excel-bi-agent
- community
Checking that the SKILL.md file is still in the repository.
Use when creating, modifying, or debugging .xlsx/.xlsm/.xlsb/.xls workbooks, VBA modules, macros, buttons, formulas, links, Power Query, or Excel COM/OpenXML automation.
Install
npx vskill@latest install 90le/microsoft-excel-bi-agent/excel-vba-workbook-engineeringSKILL.md
The same SKILL.md was published earlier as 90le/microsoft-excel-bi-agent/excel-vba-workbook-engineering.
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.
- 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:
Use 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/.xlsm without 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 .frm files for parseable procedure blocks, duplicate public standard-module entry points, and missing Option Explicit before import.
These scripts are helpers, not substitutes for judgment. Read or patch them when a workbook has special requirements.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/excel-vba-workbook-engineering/SKILL.md
Popularity
- Repository stars
- 2
- Repository forks
- 1
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/90le/microsoft-excel-bi-agent/excel-vba-workbook-engineering)