Commands & Syntax > Commands > Microsoft Excel >

Get worksheets - < excel_wb_sheets >() ... [Pro]

www.perfectkeyboard.com

 

Excel: Get worksheets
<excel_wb_sheets>(Workbook identifier,Variable for sheet names,Variable for number of sheets,Variable for active sheet)
Available in: Professional edition

This command retrieves names of worksheets (and currently active worksheet) for given workbook.

 

#

Parameter name

Parameter description

1

Workbook identifier

A workbook identifier previously obtained by "open workbook" command.

2

Variable for sheet names

Variable (array) that receives names of all worksheets.

3

Variable for number of sheets

Variable that receives number of all worksheets.

4

Variable for active sheet

Variable that receives name of currently active worksheet.

 

Example (Macro Steps):

 

1

<#> <#>This macro shows how to open and close an Excel workbook

2

Macro execution: ONLY COMMANDS

3

Excel: Open/Create workbook "" (Worksheet = "", Show = "Yes", Workbook identifier = "wbi")

4

Excel: Get worksheets (Workbook identifier = "wbi", Variable for sheet names = "vSheets", Variable for number of sheets = "vSheetNum", Variable for active sheet = "vActiveSheet")

5

Message SHOW "Information" : "The newly open workbook has: Number of sheets: %vSheetNum% The first sheet name is: %vSheets[0]% The active sheet name is: %vActiveSheet%" (other parameters: x = -100, y = -100, Window title = Excel Open/Close, Buttons = OK, Timeout (seconds) = 0, Always on top = No).

6

Excel: Close workbook "%wbi%" (SAVE = "No")

Example (Plain Text):

 

<#>This macro shows how to open and close an Excel workbook

<cmds>

<excel_wb_open>("","",1,wbi)

<excel_wb_sheets>(wbi,vSheets,vSheetNum,vActiveSheet)

<msg>(-100,-100,"The newly open workbook has:

 

Number of sheets: %vSheetNum%

The first sheet name is: %vSheets[0]%

The active sheet name is: %vActiveSheet%","Excel Open/Close",1,0,0,0)

<excel_wb_close>(%wbi%,0)