Excel Automation

Hi,

I want to export a report to excel.The data has to be exported to muliple sheets based on the label code and the label code name should be the excel worksheet name.Im doing this using automation.I tried the following code,but im getting error

Lbl.SETRANGE(Lbl.Code);
IF Lbl.FIND(’-’) THEN BEGIN
IF Lbl.FINDFIRST THEN BEGIN
Sheet:=Excel.ActiveSheet;
Sheet.Name := FORMAT(Lbl.Code);
END ;end;

Kindly help…

You didn’t state what error you get . This is what I do to add a new worksheet and apply a label.

This is code used for the original sheet. Text010 is defined in the Text Constants in the C/AL Globals.
xlWorkbooks.Add;
xlWorkbook := xlApp.ActiveWorkbook;
xlWorksheet := xlApp.ActiveSheet;
xlWorksheet.Name := Text010;

To add an additional sheet and apply a label do the following: The label is based on your variable name.

xlWorkbook.Worksheets.Add;
xlWorksheet := xlApp.ActiveSheet;
xlWorksheet.Name := FORMAT(lblCode);

Hope this helps.

Look at this link

http://www.mibuso.com/forum/viewtopic.php?f=23&t=25482

http://www.mibuso.com/forum/viewtopic.php?t=12014