exceloffice-scriptsexcel-solver

Run Excel Solver using Office Scripts (not VBA)


I need to automate a simple pipeline which runs the Excel Solver. I'd like to use Office Scripts (TypeScript https://learn.microsoft.com/en-us/javascript/api/office-scripts/overview?view=office-scripts). I've written a VBA script which works, but would rather use Office Script because it is a more robust language, and can be more easily integrated into cloud-based pipelines.

Example VBA script:

' Initialize inputs
Range("$A$1:$A$3").Value = 0

' Run solver
SolverSolve

Desired Office Scripts

function main(workbook: ExcelScript.Workbook) {

    // Initialize inputs
    let currentWorksheet = workbook.getActiveWorksheet();
    currentWorksheet.getRange("$H$16:$H$24").setValue(0);

    // Run solver
    <<Insert Office Script code here>>
}

I don't see the Solver in the ExcelScript API https://learn.microsoft.com/en-us/javascript/api/office-scripts/excelscript?view=office-scripts. Am I missing something, or is there any other way to get the Solver to run using Office Script?


Solution

  • Put simply, the answer to your question is no, you cannot access solver via Office Scripts or any other web based technology supported by Excel.

    See the below document for confirmation.

    https://support.microsoft.com/en-us/office/define-and-solve-a-problem-by-using-solver-5d1a388f-079d-43ac-a7eb-f63e45925040#OfficeVersion=Web