Automation & Advanced Features¶
Extend Excel workflows with code and specialized automation. Run macros and Python, solve scenarios with Goal Seek and data tables, control windows, and integrate structured XML data.
VBA Macros (11 operations)¶
- Inspect code: List procedures with their kinds and line numbers, read a selected procedure or up to 500 lines, or view the full module.
- Maintain code: Import standard modules, update whole modules, replace one procedure only when its source has not changed, or remove components.
- Run procedures: Execute existing VBA procedures with supported parameters.
- Find source: Search literal text across modules with limited matches, line numbers, and short excerpts.
- Diagnose project access: Inspect actual access, password protection, and execution mode without changing settings.
- Inspect dependencies: List library references and flag broken ones without automatic repair.
Listing or editing the VBA project requires Excel's manually configured trust setting. Running an existing macro does not require project-inspection trust, but Excel's macro security still applies. ExcelMcp does not enable trust or bypass security automatically. Retain a macro-enabled file format when saving code. Normal opens disable VBA macros, including .xlsm files. Enabling execution requires separately approving a saved-only reopen; opening event code can run. Replacing procedure source confirms only that Excel stored the text; it does not confirm that the code compiles or runs correctly. Procedure replacement preserves introductory comments and surrounding blank lines. The status action reports blocked project access rather than guessing protection or execution mode when access is denied.
Python in Excel (2 operations)¶
- Add Python calculations: Write Python-in-Excel formulas that can reference live worksheet data.
- Read results: Wait for cloud execution and read supported calculated values, distinguishing pending work from unavailable Python support.
This is Microsoft's licensed Python in Excel service, not local Python execution. It requires a supported Microsoft 365 account and internet access. Rich Python objects are not necessarily readable as ordinary values through Excel automation; choose worksheet-value output when that is what the task needs.
A successful formula write does not mean the cloud calculation has finished. An unavailable service and pending calculation need different recovery choices.
Cloud calculation and failure guidance
Window Management (17 operations)¶
- Watch work live: Show, hide, position, and arrange the session's Excel window.
- Inspect context: Read its active worksheet, selection, chart, window state, and view.
- Improve navigation: Adjust zoom, display options, frozen panes, and movable splits.
- Prepare the opening view: Set a sheet's scroll position and optional selection, check the actual view, then explicitly save the workbook.
- Show progress: Set and clear Excel status-bar text.
Preserve the user's existing visibility preference. Keeping a workbook open does not mean showing its window. Window changes affect the selected session, not unrelated Excel processes, and visible interaction needs a suitable desktop.
What-If Analysis (8 operations)¶
- Find an input: Use Goal Seek to adjust one input until a formula reaches a numeric target.
- Compare assumptions: Maintain named scenarios, apply their input values, and produce scenario summaries.
- Explore sensitivity: Build one- or two-variable Excel data tables.
Goal Seek and applying scenarios change live cells; they are not read-only inspection. Read the resulting inputs and outputs. Data tables can be calculation-intensive and need the worksheet layout prepared first.
Solver is not exposed here. It is an optional VBA add-in that requires separate user configuration and macro-security decisions.
XML Maps (6 operations)¶
- Map structured data: Manage workbook XML schemas and bind worksheet cells or columns to XML paths.
- Exchange data: Import and export mapped XML without dialogs.
Use existing mappings when they describe the intended data. Imports can write worksheet cells or create a new mapped Table. Removing a map does not clear previously imported cells.
External schema dependencies, DTDs, and schema-location attributes are rejected so Excel cannot resolve unexpected external resources.
Batch jobs (1 operations)¶
- Run known sequences: Run commands in order in one call, with numbered results and optional stopping after ordinary errors; always stop when completion is uncertain.
Use MCP batch action run or excelcli batch. Both accept the same command entries and continue after errors by default, with an option to stop. Each result identifies its input position. Timeouts, cancellation, and reported unknown completion always stop further commands because Excel work may still be running.
Batches do not roll back after failure or automatically undo or save changes. Individual commands can save or discard edits.
Batch inputs, results, and session handling
Related feature areas¶
- Data & analytics - combine code with queries and analytical models
- Cells & workbooks - manage the inputs, formulas, and files used by automation
- Charts & visualization - present automated results
- Real Excel automation vs. file-parser libraries