Mirror

Check for an existing worksheet in Excel (Views: 100)


Problem/Question/Abstract:

How can I check if a work sheet (e.g. 'first') is existing in an Excel file?

Answer:

In late binding:

{ ... }
WB := Excel.Workbooks[1];
for Idx := 1 to WB.Worksheets.Count do
  if WB.Worksheets[Idx].Name = 'first' then
    Showmessage('Found the worksheet');
{ ... }

<< Back to main page