Scripting and Macros


This scripts gets the workbook properties

function main(workbook: ExcelScript.Workbook) { 

   const _properties = workbook.getProperties();
   const _title = properties.getTitle();
   const _subject = properties.getSubject();
   const _author = properties.getAuthor();
   const _comments = properties.getComments();

   const _dataProperties : i_WorkbookMetaData = {
      title : _title || "(Not Set)"
      sibject : _subject || "(Not Set)"
      author : _author || "(Not Set)"
      comments : _comments || "(Not Set)"
   };

   displayPropertiesInSheet(workbook, _dataProperties);
}

interface i_WorkbookMetaData{
   title : string;
   subject : string;
   author : string;
   comments : string;
}

function displayPropertiesInSheet(
   workbook: ExcelScript.Workbook,
   properties: i_WorkbookMetaData) {

   const _sheet = workbook.getActiveWorksheet();
   const _headerRange = _sheet.getRange("A1:B1");
   _headerRange.setValues([["Property","Value"]]);
   const _dataRange = _sheet.getRange("A2:B5");
   const _propertiesArray = [
      ["Title", properties.title],
      ["Title", properties.title],
      ["Title", properties.title],
      ["Title", properties.title],
   ];
   _dataRange.setValues(_propertiesArray);
}


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext