Skip to content

UserForm Specification

src/forms/specs/<FormName>.yaml is the source-controlled Designer specification for a UserForm. xlflow form build validates this contract before opening Excel.

Minimal Authoring Spec

xlflow form new SampleForm creates an authoring-focused starting point:

yaml
schemaVersion: 1
kind: xlflow.userform
basis: designer
form:
  name: SampleForm
  caption: SampleForm
controls: []

Do not add snapshot-oriented fields such as warnings to a new spec unless they came from form snapshot or another capture workflow.

Document Fields

FieldTypeRequiredRules
schemaVersionintegerYesMust be 1.
kindstringYesMust be xlflow.userform.
basisstringYesMust be designer.
coordinateSystemstringNopoints or parent-relative.
formobjectYesForm metadata and build intent.
controlsarrayYesFlat array of control mappings.
warningsarrayNoSnapshot-only capture metadata; omit from hand-authored specs.

Form Fields

FieldTypeRequiredSupport
namestringYesSupported. VBA UserForm component name.
captionstringNoSupported.
width, heightnumberNoBest-effort. Verify the rebuilt form in Excel.
buildobjectNoSupported build intent: caption, width, height.
observedobjectNoSnapshot-only captured state: caption, width, height, insideWidth, insideHeight.

Controls

Every authored control requires id, name, and type. Controls are a flat list; use parentId to place a child inside a container.

Common fieldTypeSupportNotes
idstringSupportedStable, unique identifier used by parentId.
namestringSupportedVBA control name.
typestringSupportedOne of the built-in types below, or a custom type with progId.
progIdstringSupportedMust match a known built-in type when both are known.
parentIdstringSupportedMust reference another control ID; only Frame is a built-in container.
zIndexintegerSupportedSibling ordering hint.
left, top, width, heightnumberSupportedDesigner coordinates in points.
tabIndexintegerSupportedDesigner tab order.
enabled, visiblebooleanSupportedInitial control state.
observed, unsupportedobject / string arraySnapshot-onlyCaptured state; do not use as normal authoring fields.
controlsarraySnapshot-onlyLegacy nested form accepted for compatibility; prefer flat controls plus parentId.
propertiesobjectCustom/uncheckedUnchecked property bag; avoid it in hand-authored built-in controls.

Built-in Control Types

TypeDefault progIdType-specific properties
LabelForms.Label.1caption (string)
TextBoxForms.TextBox.1text (string), value (any)
ComboBoxForms.ComboBox.1text (string), value (any), list (string array), selectedIndex (integer)
ListBoxForms.ListBox.1text (string), value (any), list (string array), selectedIndex (integer)
CommandButtonForms.CommandButton.1caption (string)
CheckBoxForms.CheckBox.1caption (string), value (any)
OptionButtonForms.OptionButton.1caption (string), value (any)
FrameForms.Frame.1caption (string); the built-in container type

ComboBox and ListBox list and selectedIndex are observed-only: xlflow attempts to apply them, but round-trip fidelity is not guaranteed.

Parent and Custom-Control Rules

  • IDs must be unique; parentId must resolve to an existing ID.
  • A control cannot parent itself, and parent references cannot form a cycle.
  • A built-in child can only use a built-in container (Frame) as its parent.
  • A custom type requires an explicit custom progId. xlflow validates common fields but emits a custom/unchecked warning because type-specific properties cannot be verified.

Support Levels

LevelMeaning
Supportedxlflow validates and applies the field as part of the normal Designer build.
Best-effortxlflow attempts to apply it; inspect the rebuilt form to confirm the result.
Observed-onlyCaptured list state that may be applied best-effort but is not guaranteed to round-trip.
Snapshot-onlyCapture metadata, not normal authored build intent.
Custom/uncheckedAccepted for compatibility, but xlflow cannot validate detailed control-specific behavior.

Validation and Editor Diagnostics

form build reports all detected contract issues before Excel opens. YAML files directly under the configured src/forms/specs directory receive the same live diagnostics in the xlflow LSP.

The LSP also provides context-aware completion and Hover for known UserForm YAML fields, built-in control types, and built-in ProgIDs. Hover shows the expected value type, required status, applicable controls, support level, and build limitations. In particular, width and height are best-effort; list and selectedIndex are observed-only state that may be applied best-effort; and warnings, observed, unsupported, and properties are snapshot-oriented or custom/unchecked metadata rather than guaranteed normal build inputs.

CodeMeaning
UFY001YAML parse error.
UFV001UFV005Unknown field, invalid value type/fixed value, missing required field, or unsupported property.
UFV006UFV012Unsupported control type, duplicate ID, invalid parent reference, parent cycle, invalid parent type, or type/ProgID mismatch.
UFV013UFV014Support-level warning or custom-control validation warning.

For a Designer capture, use xlflow form snapshot <FormName> --out src/forms/specs/<FormName>.yaml. Captured warnings, observed, and other snapshot fields are preserved for review, but new authoring should begin with the minimal form above. Keep authored specs directly in src/forms/specs/ so the LSP recognizes them; files outside that configured location are intentionally ignored.

Released under the MIT License.