Error Message When Saving File...

Hi Adrian,


A client reported the following error:

"To save this file, you must select a visible sheet."

from  _UExcelRecords.TWorkbook (TWorkbook.FixSheetVisible)

This fired when a FlexCel file object was saved to a memory stream. The file, which I don't have access to, contained data to be imported into the application. Any idea what the problem is? How can I check and avoid this in future?

Thanks,

Steve

Hi,

This problem normally means what it says: The xls.ActiveSheet is not a visible sheet. This would create a file that would crash Excel.

You can check if the selected file is visible by checking:
if (xls.SheetVisible <> TXlsSheetVisible.Visible) then...

And then you can select a valid sheet by setting xls.ActiveSheet := sheet;

Probably you can make a loop and select the first visible sheet in order to save. But the sheet you select is the sheet that will be selected when you open the file in Excel.

Awesome - Thanks!!