Getting started
Playground
A page where you can write and run RAS without installing anything. The compiler and the Excel stand-in are compiled to WebAssembly and everything runs inside the browser (neither source nor workbooks are sent anywhere).
Samples
Open them from "New / samples…" at the top. Each sample's workbook has buttons and controls with its macros assigned: switch the right end of the "Workbook" tab's ribbon to "▶ Run" mode and press the buttons on the sheet to run the macros (the same as the run mode of the sheet preview; spec §14.10.10).
| Sample | What it shows |
|---|---|
| Hello | A macro that writes a table and formulas from an array of structs, with its buttons. Tests in test/ |
| OrderSheet | An order sheet of ActiveX controls (a combo box, a spin button, a check box, a command button) and the sheet's events (Change, SelectionChange, BeforeDoubleClick) and Workbook.Open. readTable reading columns by their headings, totals with a Map |
| Forms | A user form: input validation (validation), placeholders, resizing (resizable) with anchors, the arguments of new and the value of showModal() |
| Dialogs | msgBox, inputBox, dialogs built from code alone (choose, Dialog, Progress), how a run-time error is shown |
| DataTools | Parsing CSV (csv), regular expression literals, readTable / writeTable, totals with a Map, JSON (json), tests |
| SalesReport | examples/sales-report (in Japanese) |
What you can do
- It converts what you write to VBA as you type and shows it, and shows errors and warnings in the editor (choose a code in "Problems" to see its
ras explaindescription). - It completes as you type (the same compiler completion as the VS Code extension: members after
., names in scope,exports of other modules (choosing one adds animport), parameter names of named arguments after(and,, and Excel functions insidefxformulas. Ctrl+Space also opens it). - Hovering over a name shows its type, signature, and description (hover), and typing
(or,in a call shows the signature and the argument you are writing (parameter info. Ctrl+Shift+Space also opens it, and Esc closes it). - ▶ Run (with "Run tests" in the ▼ on its right) runs without Excel just like
ras run/ras test.msgBox/inputBoxare shown as dialogs, and the changed cells and the workbook grid (ras book view) are displayed. - "Generate test" above an
exported function insrc/adds a test skeleton for that function totest/<module>.test.rasand opens it (the same as the VS Code extension's CodeLens. Spec §14.12.10). - "Download as .xlsm" saves a macro-enabled workbook with the generated VBA written to it (
ras pack. With "Load a workbook (.xlsx / .xlsm)…" at the end of the sample list, you can write to your own .xlsx / .xlsm). In the VBA tab, you can also save the.bas/.clsof each module. - In the Explorer on the left (the same folder tree as VS Code; Ctrl+B shows or hides it), you can open, add, rename (F2), and delete files (also from the right-click menu). The editor tabs are the open files, and closing a tab leaves the file in place.
- "New form" in the Explorer adds a user form (
forms/<name>.form.jsonand code-behind), which you can edit in the same designer as the VS Code extension. Double-clicking a control adds an event handler. A form shown during a run appears on top of the page and can be operated (image settings are available only in the VS Code extension). - In the "Workbook" tab, you can add events to shapes and controls placed on a sheet from the right-click menu (
@on("CommandButton1.Click")inobjects/<code name>.ras; for shapes and Form controls,@on("Button 1.Click")). You can edit the text of a control in place with F2. For sheet editing operations, see Edit workbooks. - "Copy URL for sharing" in the ▼ to the right of "Download as .xlsm" turns the project's files into a URL you can hand over. The editor's right-click menu or Shift+Alt+F formats the file.
- In the browser's developer tools (F12) "Sources", you can place breakpoints in the
.rasfiles underras://project/…, step through, and inspect variables. If you writedebugger;in the source, execution stops on that line (nothing is output to VBA. Spec §14.10.9 and §14.10.10).
What you cannot do
Syncing with Excel itself (ras sync) and running with Excel are available only in the VS Code extension and the CLI. Features missing from the Excel stand-in (such as calling handwritten VBA) produce errors in the playground just as with ras run (Run without Excel).
Links shared with the old address (https://cool0707.github.io/ras/#code=…) still open in the playground as they are.
How to develop the playground (build and test) is described in web/README.md.