Skip to content

xlflow macros ​

Discover runnable workbook macro entrypoints without executing user code.

Usage ​

bash
xlflow macros [--session] [--runnable]

Options and Arguments ​

Option / argumentDescriptionDefault
--sessionRead macro metadata from the managed live workbook.false
--runnableShow only macros that are directly runnable.false
--jsonReturn full macro metadata as structured JSON.false

Examples ​

bash
xlflow macros
xlflow macros --session --json
xlflow macros --runnable --json

Notes ​

Macro procedure names may use Unicode VBA identifiers; discovered name and qualified_name values preserve those names.

TIP

Run macros --json before run so agents can choose an exact entrypoint. Use --runnable to filter out non-runnable procedures (those with parameters, event handlers, or on unsupported component types). The injected runner can invoke no-argument private, public, and friend procedures in standard, class, and workbook document modules.

IMPORTANT

This command inspects workbook state; it does not execute discovered macros.

JSON Output Example ​

Successful --json output uses the xlflow envelope plus command-specific fields.

json
{
  "status": "ok",
  "command": "macros",
  "default_entry": "Main.GenerateQRCode",
  "macros": [
    {
      "module": "Main",
      "name": "GenerateQRCode",
      "qualified_name": "Main.GenerateQRCode",
      "kind": "sub",
      "args": [],
      "line": 2,
      "component_type": "standard_module",
      "visibility": "Public",
      "has_parameters": false,
      "runnable": true,
      "reason_not_runnable": null,
      "run_command": "xlflow run Main.GenerateQRCode --session --json"
    },
    {
      "module": "Sheet1",
      "name": "Worksheet_Change",
      "qualified_name": "Sheet1.Worksheet_Change",
      "kind": "sub",
      "args": ["Target As Range"],
      "line": 1,
      "component_type": "document_module",
      "visibility": "Public",
      "has_parameters": true,
      "runnable": false,
      "reason_not_runnable": "has_parameters",
      "run_command": null
    }
  ],
  "suggestions": [
    {
      "title": "Run the default entrypoint",
      "command": "xlflow run Main.GenerateQRCode --session --json"
    }
  ]
}

Field Reference ​

Each macro entry in the macros array includes:

FieldTypeDescription
modulestringVBA component (module) name.
namestringProcedure name.
qualified_namestringFully qualified name (Module.Procedure). Use this with xlflow run.
kindstring"sub" or "function".
argsstring[]Raw parameter declarations (e.g. "path As String").
linenumber1-based line number in the source module.
component_typestringOne of: standard_module, class_module, document_module, userform, unknown.
visibilitystringDeclared visibility: "Public", "Private", "Friend", or "Implicit".
has_parametersbooleanWhether the procedure declares parameters.
runnablebooleanWhether the macro can be run directly via xlflow run.
reason_not_runnablestring?If not runnable, why: has_parameters, event_procedure, unsupported_component_type.
run_commandstring?Ready-to-use xlflow run command (only present when runnable is true).

Top-level Fields ​

FieldTypeDescription
default_entrystring?The project.entry from xlflow.toml if it matches a runnable macro.
suggestionsobject[]Suggested next commands, each with title and command.

Runnable Determination ​

A macro is considered runnable when all of the following are true:

  • has_parameters is false (no parameters)
  • Not an event procedure (e.g. Workbook_Open, Worksheet_Change, Auto_Open)
  • component_type is standard_module, class_module, or document_module (not userform or unknown)

When to use this command ​

Use xlflow macros when the task matches the command description above. For a goal-oriented workflow, start with the How-to guides and return here for exact options.

Prerequisites ​

Check the project configuration and run xlflow doctor --json before workbook-backed operations. Source-only commands can run without Excel; commands that read or mutate a workbook require Windows Excel and VBIDE access.

What this command reads and changes ​

The command reads the inputs and configuration described in its syntax and examples. Treat source files, the saved workbook, and a live session as separate states; add --session when the live workbook is authoritative. Any mutation is reversible only when a backup or explicit session save boundary exists.

Effect on source-of-truth state ​

Use xlflow status --json before and after the command. A source edit normally requires push; a workbook edit normally requires pull; a dirty live session requires save --session or an intentional discard.

Common workflows ​

Combine this command with the relevant source/workbook/session workflow, and use --json in scripts and agent loops.

Common failures ​

Read the structured error.code, exit code, and recovery metadata instead of scraping terminal text. The symptom-oriented troubleshooting guide maps installation, execution, session, VS Code, and WSL failures to recovery steps.

Released under the MIT License.