prompt() isn’t available in ONLYOFFICE macros. Since v7.1 macros run in strict mode, so access to window, document, and alert is restricted — and prompt() / confirm() fall under the same limitation. See Getting started.
Workaround: put the inputs in fixed cells and read them from the macro:
js
(function () {
let sheet = Api.GetActiveSheet();
let amount = sheet.GetRange("B1").GetValue();
let category = sheet.GetRange("B2").GetValue();
sheet.GetRange("D1").SetValue(amount);
sheet.GetRange("D2").SetValue(category);
})();
If you need a real input dialog, that requires a plugin rather than a macro.
So is there no easy way to write a macro to select cell A1, ask the user to input a value for that cell, then jump to cell B1 and ask for a value, etc?
I am migrating from excel and know no JavaScript.
If this cannot be achieved fairly easily, I will need to return to excel.
I am too old to start learning programming languages, but I am keen to move away from Microsoft products.
For that exact workflow, unfortunately there isn’t an InputBox-style function in ONLYOFFICE macros, so a macro can’t stop at A1, wait for input, then continue to B1, etc. A proper input dialog would require a plugin.
A simpler workaround is to enter the values directly in the row and use the macro for the repetitive part:
(function () {
let sheet = Api.GetActiveSheet();
sheet.GetRows("2").Insert("down");
sheet.GetRange("A2").Select();
})();
So the flow would be: enter values → run the macro → a new row is added and A2 is selected.
If you tell me where your totals are and where they should go on the Summary sheet, I can add that part too.
This macro inserts a new row at the top of Summary, copies the values from Sheet1, and clears Sheet1 for the next entry:
js
(function () {
let source = Api.GetSheet("Sheet1");
let summary = Api.GetSheet("Summary");
// Insert a blank row at the top of Summary (below the titles in row 1)
summary.GetRange("A2:D2").Insert("down");
// Copy the values from Sheet1 to the new top row
summary.GetRange("A2").SetValue(source.GetRange("A2").GetValue());
summary.GetRange("B2").SetValue(source.GetRange("B2").GetValue());
summary.GetRange("C2").SetValue(source.GetRange("C2").GetValue());
summary.GetRange("D2").SetValue(source.GetRange("D2").GetValue());
// Clear Sheet1 for the next entry
source.GetRange("A2:D2").Clear();
})();
Type your values on Sheet1, run the macro, and they move to a new top row on Summary.
Just make sure the sheet names match yours exactly (case matters), and adjust the columns if you use more or fewer than A–D.
That happens because SetValue copies only the value. Use Copy instead — it brings the formatting across too:
js
(function () {
let source = Api.GetSheet("Sheet1");
let summary = Api.GetSheet("Summary");
// Insert a blank row at the top of Summary
summary.GetRange("A2:D2").Insert("down");
// Copy the entry from Sheet1 (values + formatting)
source.GetRange("A2:D2").Copy(summary.GetRange("A2:D2"));
// Clear Sheet1 for the next entry
source.GetRange("A2:D2").Clear();
})();
Just the one Copy line replaces the four SetValue lines.