Checks If a Worksheet Exists

Verb: excelWorksheetExists

Available from: <Standard>

Checks whether a spreadsheet exists in an Excel file by searching for its name or index.

Syntax

excelWorksheetExists --file(Excel) [--index(Numeric)] [--name(String)] (Boolean)=value

Inputs

Script Designer Required AcceptedTypes Description
--file Excel Required Excel Excel file used for checking the existence of the worksheet.
--index Index Optional Number Index of the desired worksheet.
--name Name Optional Text Name of the desired worksheet.

Outputs

Script Designer AcceptedTypes Description
value Exist Boolean Returns "True" if the search object worksheet was found, or "False" otherwise.

Example

The Open Excel File command opens an Excel file and returns it to the variable "excelFile", which is entered in the Excel parameter of the Checks If a Worksheet Exists command. This command checks whether the worksheet of index "1" exists in the file and returns a variable with the result "True", confirming its existence.

defVar --name excelFile --type Excel
defVar --name worsheetExists --type Boolean
excelOpen --file "cloneExcelFile.xlsx" excelFile=value
excelWorksheetExists --file ${excelFile} --index 1 worksheetExists=value
logMessage --message "${worksheetExists}" --type "Info"
excelClose --file ${excelFile} --save
// Result: True 
// Index worksheet "1" exists in excel file.
Download File

Remarks

For the correct operation of the Get Excel Table command, an Excel file must be opened with the command Open Excel File.

The Save Excel As command can be used to save changes made to the file.

See Also

  • Assign Value to Office
  • Attach Office Application
  • Clone Excel Spreadsheet
  • Close Excel
  • Close Office Application
  • Convert Excel from XLS to XLSX
  • Create from Data Table
  • Create Office File
  • Excel Calculate Formula
  • Excel Merge
  • Export Office File As
  • Get Excel Table
  • Get Excel Value
  • Get Office Text
  • Get Office Value
  • Get Text from File
  • Go to Location in Office
  • Insert Data Table into Excel File
  • Open Excel File
  • Open Office File
  • Print Office File
  • Refresh Office Application
  • Rename Excel Worksheet
  • Run Macro in Excel
  • Run Macro Office
  • Save Excel As
  • Save Office File
  • Save Office File As
  • Set Value in Excel