Create new Workbook using OfficeScripts

Here’s an example of an OfficeScript that creates a new workbook in Excel:

function main(workbook: ExcelScript.Workbook) {
  // Create a new workbook
  let newWorkbook = ExcelScript.Workbook.createEmpty();
  
  // Save the new workbook
  newWorkbook.saveAs("NewWorkbook.xlsx");
  
  // Close the new workbook
  newWorkbook.close();
}

To use this OfficeScript, follow these steps:

  1. Open Excel Online or Excel for the web.
  2. Create a new workbook or open an existing workbook.
  3. Click on the “Automate” tab in the ribbon.
  4. Click on the “Script Lab” button.
  5. In the Script Lab pane, create a new script or open an existing one.
  6. Replace the default code in the script editor with the code provided above.
  7. Click the “Run” button to execute the script.

This script creates a new empty workbook, saves it as “NewWorkbook.xlsx”, and then closes the workbook. You can modify the file name and path in the saveAs function to save the workbook at a specific location.

Please note that OfficeScripts are currently only supported in Excel for the web and Excel Online. They are not available in the desktop version of Excel.

Pamai Tech
Turning ideas into Reality

Products

Office Add-in

Enterprise Solutions

Cloud Consulting

UI UX Design

Data Transformation

Services

FAQ's

Privacy Policy

Terms & Condition

Team

Contact Us

Company

About Us

Services

Features

Our Pricing

Latest News

© 2025 Pamai Tech