Freezepanes (excel method) sometimes gives errors

Hi,

I have a custom report that built in Axapta that generates an excel report. Periodically, the users will get this error

not sure if you can read it. It says "Method 'freezepanes in COM object of class ‘Window’ returned error code 0x800A03EC () which means: Unable to set the FreezePanes property of the Window class.

It’s not reproducible, and it happens seldom, perhaps 2% of the time. It used to happen more often, but I put a try/retry section in my code:

public void newWorksheet(String255 _worksheetName)
{
COM comWindow, comApplication, comSheet;
int retryCount = 5;
countWorksheets++;

if (worksheets.count() >= countworksheets)
{
worksheet = worksheets.itemFromNum(countWorksheets);
}
else
{
worksheet = worksheets.add(null, null, 1);
}

worksheet.name(_worksheetName);
progress = new SysOperationProgress();
progress.setAnimation(#AviUpdate);
progress.setCaption(_worksheetName);
currentRow = 1;

comApplication = application.comObject();
comSheet = worksheet.comObject();
comSheet.activate();
comWindow = comApplication.activeWindow();
comWindow.splitRow(1);

try
{
comWindow.freezePanes(true);
}
catch(Exception::Error)
{
retryCount–;
if(retryCount > 0)
retry;
else
throw(Exception::Error);
}
}

While this helped, it’s just a band-aid and I’m still wondering what the root cause is. Does anyone know?