Options

Excel: two sheets in one Workbook

UmknixUmknix Member Posts: 11
My problem:
I want to fill 2 sheets in an existing workbook. The first one is filled correctly, :D but the second one is still empty.
I fill table 370 with two record.variables and fill the first sheet with

TempExcelBuffer.OpenBook(FileName,sheetname);
TempExcelBuffer.CreateSheet(sheet,File,COMPANYNAME,USERID);

What about the second? I tried as follows:

TempExcelBuffer := OtherTempExcelBuffer;
TempExcelBuffer.CreateSheet(NEWsheet,File,COMPANYNAME,USERID);

It produces an error (translated :? ) : I'm not allowed to give the same name to a sheet, object library or workbook which refers to Visual Basic.

What do I have tot do? #-o

Comments

  • Options
    SaalekSaalek Member Posts: 181
    Hi
    Try this to add the second sheet (In CreateSheet function, you must separate 2 cases: the first sheet and the rest of sheets)

    If is the first sheet
    xlsheet := xlapp.ActiveSheet
    
    else
    IF NOT ISCLEAR(xlsheet) THEN
    CLEAR(xlsheet);
    CREATE(xlsheet);
    xlsheet:=xlbook.Worksheets.Add;
    xlsheet.Select;
    xlsheet.Name:='SheetName';
    

    Bye
Sign In or Register to comment.