How To Retrieve Multiple Excel Sheet Names

hello everybody.

i’m trying to retrieve the Sheets Names of an excel workbook. i’ve tried lots of things but nothing is working and i cant find a post here that answers me.

there’re multiple sheets and i want to store them in a table in Nav

so any suggestions ?

Thank You.

OK. Finally I got it after several and several of tries

and here’s the Code:

Variables:

ObjExcel Automation ‘Microsoft Excel 12.0 Object Library’.Application

ObjWorkBook Automation ‘Microsoft Excel 12.0 Object Library’.Workbook

ObjWorkSheet Automation ‘Microsoft Excel 12.0 Object Library’.Worksheet

Code:

IF ISCLEAR(ObjExcel) THEN CREATE(ObjExcel);

ObjExcel.Visible(TRUE);

FilePath := Wind.OpenFile(‘Import File’,’’,2,’’,0);

ObjWorkBook := ObjExcel.Workbooks.Open(FilePath);

ObjWorkBook := ObjExcel.ActiveWorkbook;

FOR i := 1 TO ObjWorkBook.Worksheets.Count DO BEGIN //Get All Sheets Names

ObjWorkSheet := ObjWorkBook.Worksheets.Item(i);

SheetsNames[i] := ObjWorkSheet.Name;

END;

// Now you have sheet names in SheetsNames Array

CLEAR(ObjExcel);

Hi! This is good. I have a very close problem and my approach is similar to yours. I am trying to update a complex spreadsheet, with macros and rules. I need to be able to obtain a sheet, and move to specific cells to dump data. I can easily do it when I create my own sheet, but problem is picking and getting control of a sheet in a file. So far, I have added navigation options to the report and am able to navigate and select a file on the drive, and also select a sheet in the file, but that is about it. Attempt to update throws this error:

This automation variable has not been instantiated. You can instantiate it by either creating or assigning it.

What am I missing?

Robert