CloseWorkbook() and its interoperation with MS Office

  • 6 August 2021
  • 2 replies
  • 40 views

Badge

This is AIMMS 4.37.4.

I’m in an institutional computing scenario that has an institution-wide subscription to Microsoft Office 365. Due to my changeover from fulltime employee to contract consultant, my use of Office 365 is temporarily suspended and this energy modeling suite I run that uses AIMMS (I didn’t write the AMS code, which is why the use of a newer version of AIMMS is contraindicated) and AIMMS is stopping and throwing this in aimms.err:

spreadsheet::CloseWorkbook(CoalOutput-1.xls, 1) failed: Error when enabling user alerts in Excel. Unknown error 0x800A03EC.

Ultimately an excel.exe process is left behind taking up CPU time indefinitely.

It seems that there is something about CloseWorkbook() that is doing more than just opening and writing a file. Is it the case that this function reaches out to Excel to get it to do something, and if so is there a workaround? I note that these spreadsheet-related functions can be made to traffic in .ods files (LibreOffice/OpenOffice) instead and I could possibly hack in an .ods/.xls conversion via command line to run after the fact using one or the other of those apps, but I wanted to see if a cleaner workaround existed.

BTW, if this behavior does not exist in the newer AIMMS version’s spreadsheet functions, it might be worth it to rewrite the modeling system’s .ams files and use a newer AIMMS.

Thanks!

 

 


2 replies

Badge

I meant to say (can’t edit) that it seems that there is something about CloseWorkbook() that isn’t just directly performing a file operation solely within its own code. Without a valid Office 365 subscription, you can’t save your document either; the action of CloseWorkbook() seems analogous.

Userlevel 4
Badge +1

Hi @jlh2002 ,

Indeed, spreadsheet functions are using the Excel installation on your computer. If you do not have Excel installed, those functions will not work.

That is one of the reasons we chose to create the AIMMSXLLibrary, that doesn't need Excel to be installed. 

I would strongly advise you to rewrite that part of the modeling system to use AIMMSXLLibrary if you can, since spreadsheet functions are deprecated.

Does it help ?

Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator