Object: Workbook
- Updated2024-09-12
- 1 minute(s) read
Object: Workbook
The Workbook object corresponds to an Excel workbook.
The following example creates an Excel workbook and fills a cell with the value 3.14:
VBScript | Python |
Dim oMyWorkbook, oMySheet Set oMyWorkbook = CreateExcelWorkbook() Set oMySheet = oMyWorkbook.Worksheets(1) oMySheet.Cells(1, 1).Value = 3.14
The following example creates an Excel workbook, fills the first worksheet with random values, and highlights the cells containing the value 47 with a red background:
VBScript | Python |
Dim iRow, jCol, oMyWorkbook, oMySheet, oMyCell Set oMyWorkbook = CreateExcelWorkbook() Set oMySheet = oMyWorkbook.Worksheets(1) For iRow = 1 to 1000 For jCol = 1 to 20 Set oMyCell = oMySheet.Cells(iRow, jCol) oMyCell.Value = Round(Random(100)) IF oMyCell.Value = 47 THEN oMyCell.Interior.Color = RGB(255, 0, 0) Next Next Call oMyWorkbook.SaveAs(DataWritePath & "Test.xlsx")