DIAdem Help

Content Type
Programming Language
Current manual

Object: Workbook

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:

VBScriptPython

 

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:

VBScriptPython

 

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")

Properties

Worksheets

Methods

SaveAs

Was this information helpful?

Previous

Objects

Previous

Objects