ActiveSheet Property

Applies to TestComplete 14.71, last modified on April 22, 2021

Note: To work with Excel files in your tests, you do not need to have Microsoft Office Excel installed on your computer.

Description

The ActiveSheet property returns the ExcelSheet object that corresponds to the Excel file’s active sheet (the sheet that was opened when the file was saved the last time).

Declaration

ExcelFileObj.ActiveSheet

Read-Only Property An ExcelSheet object
ExcelFileObj An expression, variable or parameter that specifies a reference to an ExcelFile object

Applies To

The property is applied to the following object:

Property Value

An ExcelSheet object that corresponds to the active sheet. To perform operations over the Excel sheet, use the methods and properties of the returned object.

Example

JavaScript, JScript

function ActiveSheetExample()
{
  var fileName = "c:\\temp\\MyFile.xlsx";
  var excelFile = Excel.Open(fileName);
  var excelSheet = excelFile.ActiveSheet;
  Log.Message("The active sheet is " + excelSheet.Title);
}

Python

def ActiveSheetExample():
  fileName = "c:\\temp\\MyFile.xlsx"
  excelFile = Excel.Open(fileName)
  excelSheet = excelFile.ActiveSheet
  Log.Message("The active sheet is " + excelSheet.Title)

VBScript

Sub ActiveSheetExample
  Dim fileName, excelFile, excelSheet
  fileName = "c:\\temp\\MyFile.xlsx"
  Set excelFile = Excel.Open(fileName)
  Set excelSheet = excelFile.ActiveSheet
  Log.Message("The active sheet is " + excelSheet.Title)
End Sub

DelphiScript

procedure ActiveSheetExample;
var
  fileName, excelFile, excelSheet;
begin
  fileName := 'c:\\temp\\MyFile.xlsx';
  excelFile := Excel.Open(fileName);
  excelSheet := excelFile.ActiveSheet;
  Log.Message('The active sheet is ' + excelSheet.Title)
end;

C++Script, C#Script

function ActiveSheetExample()
{
  var fileName = "c:\\temp\\MyFile.xlsx";
  var excelFile = Excel["Open"](fileName);
  var excelSheet = excelFile["ActiveSheet"];
  Log["Message"]("The active sheet is " + excelSheet.Title);
}

See Also

ExcelFile Object
Working with Microsoft Excel Files

Highlight search results